New to Bass.net

Started by KevC, 5 Jun '24 - 17:25

KevC

Hi all.

I just downloaded bass.net for vs2022 and I am having some difficulty in actually getting any sound.

I have a premade float[] called buffer with 44100 samples in it(-1->1).  (Im assuming this would be half a second of L and R audio, packed L, R, ... ,)

The code I am using so far is...

 Un4seen.Bass.Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_16BITS, IntPtr.Zero);

_bassStream = Un4seen.Bass.Bass.BASS_StreamCreatePush(44100, 2, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE, IntPtr.Zero);

Bass.BASS_ChannelPause(_bassStream);

Bass.BASS_StreamPutData(_bassStream, buffer, buffer.Length * 4);

Bass.BASS_ChannelPlay(_bassStream, true);

Any help here would be truly appreciated.  Thanks.

Ian @ un4seen

The BASS_STREAM_DECODE flag in the BASS_StreamCreatePush call means the stream is only for decoding, not playing, so the BASS_ChannelPlay call will fail (with BASS_ERROR_DECODE error code). So you should remove that flag. You should also remove restart=true from the BASS_ChannelPlay call because that will clear the data that you previously fed via BASS_StreamPutData. It should work after that.

KevC

Thank you very much Ian, worked a treat!