This post focuses on how to do just that. If(trbVolume.Value = 0, 0, (trbVolume.A recent Java subreddit thread called " Compiling Java Packages without IDE" posed the question, "is a command that compiles a group of java files that are inside a package into a separate folder (let's just call it bin), and how would I go about running the new class files?" The post's author, kylolink, explains that "When I started out using Java I relied on Eclipse to do all the compiling for me and just worried about writing code." I have seen this issue many times and, in fact, it's what prompted my (now 4 years old) blog post GPS Systems and IDEs: Helpful or Harmful? I love the powerful modern Java IDEs and they make my life easier on a daily basis, but there are advantages to knowing how to build and run simple Java examples without them. MBassInitalized = False End Sub Private Sub AdjustPitch()īass.BASS_ChannelSetAttribute(mMP3Stream, _īASSAttribute.BASS_ATTRIB_TEMPO_PITCH, nudKey.Value)Įnd If End Sub Private Sub AdjustVolume() MMP3Stream = AddOn.Fx.BassFx.BASS_FX_TempoCreate(mMP3Stream, _īASSFlag.BASS_FX_FREESOURCE Or BASSFlag.BASS_SAMPLE_FLOAT _Įlse Throw New Exception( String.Format( " Stream error: ", _Įnd If End If End Sub Private Sub StopPlaybackBass() MMP3Stream = Bass.BASS_StreamCreateFile(mp3FileName, 0, 0, _īASSFlag.BASS_SAMPLE_FLOAT Or BASSFlag.BASS_STREAM_PRESCAN) If mBassInitalized OrElse Bass.BASS_Init(-1, 44100, _īASSInit.BASS_DEVICE_DEFAULT, Me.Handle) Then Here is the code that allows for the playback, volume control, and real-time pitch shifting:Ĭopy Code Private Sub PlayMP3Bass( ByVal mp3FileName As String)
Volume control was also needed to be able to mix volume levels from the MP3 with the singer's microphone.
The BASS Sound library was used for playback so the pitch of the MP3 could be changed in real time to adjust to the singer's key. Marshal.WriteByte(bmpData.Scan0, n, myByte( 0)) ' copy the stream of pixel For n As Integer = 0 To stream.Length - 1 Dim myByte( 0) As Byte ' create a new bitmap Dim bmp As New Bitmap(width, height, PixelFormat.Format32bppArgb)ĭim bmpData As BitmapData = bmp.LockBits( New Rectangle( 0, 0, width, height), _ MyBitmap.MakeTransparent(myBitmap.GetPixel( 1, 1))Įnd Get End Property Public Shared Function StreamToBitmap( ByRef stream As Stream, _īyVal width As Integer, ByVal height As Integer) As Bitmap ' Do nothing (empty bitmap will be returned) End Try Dim myBitmap As Bitmap = StreamToBitmap(temp, CDG_FULL_WIDTH, CDG_FULL_HEIGHT) Try Dim i As Integer = 0 For ri = 0 To CDG_FULL_HEIGHT - 1 For ci = 0 To CDG_FULL_WIDTH - 1 Dim ARGBInt As Integer = m_pSurface.rgbData(ri, ci) Here is the code that does the conversion:Ĭopy Code Public ReadOnly Property RGBImage( Optional ByVal makeTransparent _Īs Boolean = False) As = CType(mCDGFile.RGBImage, Bitmap).GetPixel( 1, 1)ĭim myFrameRate As Single = Math.Round(mFrameCount / (pos / 1000), 1)Īnother challenge that presented itself was taking a multidimensional array of integers that was created from the CDG library and converting it into a bitmap. MillisecondsRemaining = endTime.Subtract(Now).TotalMillisecondsĭim pos As Long = cdgLength - millisecondsRemainingĮndTime = Now.AddMilliseconds(millisecondsRemaining) While millisecondsRemaining > 0 If mStop Then Exit While End If MsgBox( " Cannot find a CDG and MP3 file to play together.")ĭim cdgLength As Long = mCDGFile.getTotalDurationĭim endTime = startTime.AddMilliseconds(mCDGFile.getTotalDuration)ĭim millisecondsRemaining As Long = cdgLength If mCDGFileName = " " Or mMP3FileName = " " Then Try If mMP3Stream 0 AndAlso Bass.BASS_ChannelIsActive(mMP3Stream) = _
The main playback rendering block looks like this: Render the frame of the CDG file that is at the elapsed time position of the MP3 that is playing.Determine the duration of the CDG file so that boundaries can be defined.Unzip the MP3 and CDG files into a temporary directory.This is the high level workflow for playing MP3 and CDG files together: After that, I wanted transparency and background video for the AVI rendering. After that, I wanted rendering to AVI files. Once playback was established, I wanted pitch shifting. One thing led to another, and I started porting over some C++ code that I found on Google Code. NET implementation for CDG file parsing available. BackgroundĪfter looking on the web for a while, I noticed that there was no. As a bonus, I included an MP3 + CDG to AVI conversion application which will not be discussed in this article. This is an MP3 + CDG file player application that parses CDG files and renders them in real time while an MP3 file is played.