Record card sound output with Bass library
Posted: Mon Mar 14, 2022 9:05 am
Hello everybody !
Do you have some code to record the current card sound output to a wav (or ogg file) with Bass Library ? i've this vb code from the un4ssen doc. But i find nothing into my pbi files for purebasic about a 'WaveWriter' function So i can't translate the following code to purebasic.
Bass is a great library and works fine inside my webradio purebasic project to broadcast to icecast. It'll interesting to record too.
Many thanks for your ideas ! Perhaps you know how to record from bass to wav or ogg.
Do you have some code to record the current card sound output to a wav (or ogg file) with Bass Library ? i've this vb code from the un4ssen doc. But i find nothing into my pbi files for purebasic about a 'WaveWriter' function So i can't translate the following code to purebasic.
Bass is a great library and works fine inside my webradio purebasic project to broadcast to icecast. It'll interesting to record too.
Many thanks for your ideas ! Perhaps you know how to record from bass to wav or ogg.
Code: Select all
Private _waveWriter As WaveWriter = Nothing ' make it global, so that the GC can not remove it
Private _myRecProc As RECORDPROC
Private _recHandle As Integer = 0
...
' start recording
_myRecProc = New RECORDPROC(AddressOf MyRecording)
_recHandle = Bass.BASS_RecordStart(44100, 2,
BASSFlag.BASS_RECORD_PAUSE Or BASSFlag.BASS_SAMPLE_FLOAT, _myRecProc, IntPtr.Zero)
' create a WaveWriter using the _recHandle to set the freq. and channels, but write the wave at 24-bit
_waveWriter = New WaveWriter("test.wav", _recHandle, 24, True)
Bass.BASS_ChannelPlay(_recHandle, False)
...
' when finished recording call this!
If Not (_waveWriter Is Nothing) Then
' finilize the wave file!
_waveWriter.Close()
End If
...
' the recording callback
Private Function MyRecording(handle As Integer, buffer As IntPtr, length As Integer, user As IntPtr) As Boolean
' we will get float sample data here
' so make sure the _waveWriter.OrigResolution property is set to 32
' this was automatically done, since we started recording with BASSFlag.BASS_SAMPLE_FLOAT
_waveWriter.Write(buffer, length)
Return True ' always continue recording
End Function