Author Topic: BASS_Encode_OPUS_Start not firing recordproc  (Read 495 times)


  • Posts: 93
hi ,
i am trying to encode recorded microphone output to opus (or ogg or mp3) and want to get the encoded data and i will send it to clients via websockets.
but the code above not firing the encodeproc.

Code: [Select]

        private ENCODEPROC _encodeProc;
        private RECORDPROC _recproc;
        private int recordChan, opusHandle;

void start(){
            string BassUserName = "xxx";
            string BassPassword = "xxx";
            BassNet.Registration(BassUserName, BassPassword);
            _recproc = new RECORDPROC(myrecproc);
            _encodeProc = new ENCODEPROC(myencodeproc);

           var t1 = Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
            var t2 = Bass.BASS_RecordInit(-1);
            recordChan = Bass.BASS_RecordStart(44100, 1, BASSFlag.BASS_RECORD_PAUSE, null, IntPtr.Zero);

            opusHandle = BassEnc_Opus.BASS_Encode_OPUS_Start(recordChan, "-M 80 -m 80", BASSEncode.BASS_ENCODE_AUTOFREE , _encodeProc, IntPtr.Zero);
             var r = Bass.BASS_ChannelPlay(recordChan, false);

private bool myrecproc(int handle, IntPtr buffer, int length, IntPtr user)
            return true;

 private void myencodeproc(int handle, int channel, IntPtr buffer, int length, IntPtr user)

but if i change
Code: [Select]
recordChan = Bass.BASS_RecordStart(44100, 1, BASSFlag.BASS_RECORD_PAUSE,_recproc, IntPtr.Zero);

then both procs (recordproc and encodeproc) works.
the data from recordproc does not have any sound.. just crackling effects.

Ian @ un4seen

  • Administrator
  • Posts: 22327
Re: BASS_Encode_OPUS_Start not firing recordproc
« Reply #1 on: 27 Mar '19 - 16:43 »
If you don't provide a RECORDPROC callback function in the BASS_RecordStart call then you will need to periodically call BASS_ChannelGetData to get the recorded data (and have it sent to the encoder at the same time).

Regarding the missing/crackling sound, to help narrow down what the problem is, please try running the pre-compiled RECTEST.EXE example from the BASS package (C\BIN folder) and see if you have the problem with that too. If it does have the problem then also try other (non-BASS) recording software and see whether that's affected too.