Author Topic: BASS_RecordStart with one DSP, RECORDPROC cannot be null  (Read 1334 times)

aybe

  • Posts: 145
I must set a RECORDPROC even though I don't need one, otherwise the DSP assigned to channel never receives any audio.
Tried to manually set channel, priority and user then start the DSP but it doesn't help.

Code: [Select]
_proc = RecordProc;
       
_ptrRec = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, 50, _proc, IntPtr.Zero);
_ptrRec = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, null, IntPtr.Zero);

The 2nd line works, the 3rd doesn't.

Also, I don't need to record this audio, only process it through a DSP. (It's a timecode-tracking DSP)

Thank you  :D

radio42

  • Posts: 4576
The 3rd line might fail with the "BASS_ERROR_ALREADY" error code - which you might check via BASS_ErrorGetCode:
Recording is already in progress. You must stop the current recording (BASS_ChannelStop) before calling this function again.

aybe

  • Posts: 145
Yes I know; I did put both for the example, I mean I try either the 2nd or the 3rd.

Code: [Select]
_proc = RecordProc;
            _ptrRec = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, 50, _proc, IntPtr.Zero);
            // _ptrRec = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, null, IntPtr.Zero);
            if (_ptrRec == 0)
                ErrCheck();

So this works, but not the declaration without a RECORDPROC.

Thank you.

radio42

  • Posts: 4576
And what error code do you get?

aybe

  • Posts: 145
Let me clarify,

- When i use a RECORDPROC, my DSP receives data, it works.
- When i don't use a RECORDPROC, there are no errors when checking for one, the DSP has the correct handles, however its callback is never triggered.

I have no way to find out what happens since it's inside BASS.

Here is the code that works.

Code: [Select]
private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (!Bass.BASS_RecordInit(-1))
                ErrCheck();

            _proc = RecordProc;
            _ptrRec = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, 50, _proc, IntPtr.Zero);
            // _ptrRec = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, null, IntPtr.Zero);
            if (_ptrRec == 0)
                ErrCheck();

            _dspNoiseGate = new DSPNoiseGate(_ptrRec, 100, IntPtr.Zero);
            _noiseGateUserControl.SetDsp(_dspNoiseGate);

            if (!Bass.BASS_ChannelPlay(_ptrRec, false))
                ErrCheck();
        }

        private bool RecordProc(int handle, IntPtr buffer, int length, IntPtr user)
        {
            if (length > 0 && buffer != IntPtr.Zero)
                return true;

            return false;
        }

        public static void ErrCheck()
        {
            BASSError bassErrorGetCode = Bass.BASS_ErrorGetCode();
            bool b = bassErrorGetCode != BASSError.BASS_OK;
            if (b)
            {
                MessageBox.Show(bassErrorGetCode.ToString());
            }
        }


If you comment the 1st _ptrRec assignation and uncomment the 2nd, it doesn't work anymore but the pointer is indeed valid, thus no errors triggered.

Makes sense ?

I can make a video for you to see,

Thank you !