Author Topic: New to Bass.net  (Read 271 times)

KevC

  • Posts: 14
New to Bass.net
« on: 5 Jun '24 - 17:25 »
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...

 
Code: [Select]
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

  • Administrator
  • Posts: 25872
Re: New to Bass.net
« Reply #1 on: 5 Jun '24 - 18:01 »
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

  • Posts: 14
Re: New to Bass.net
« Reply #2 on: 5 Jun '24 - 19:22 »
Thank you very much Ian, worked a treat!