Author Topic: Sound Card Based Signal Generator (Bass.Net)  (Read 74 times)

tumanovalex

  • Posts: 17
I would like to create a signal generator of various shapes (including constant level signals). I just need to output the signal (for example, sinus) to the output of the sound card, without recording the signals in the file and reproducing it from the file. I'm a little confused about Bass.Net documentation. Please tell me what Bass_Stream methods need to be used to solve this problem?

tumanovalex

  • Posts: 17
Re: Sound Card Based Signal Generator (Bass.Net)
« Reply #1 on: 15 May '21 - 20:26 »
I tried to do this:
Code: [Select]
int sample = Bass.BASS_SampleCreate(256, 440 * 64, 1, 1, BASSFlag.BASS_SAMPLE_LOOP | BASSFlag.BASS_SAMPLE_OVER_POS);
if (sample == 0)
  ShowMes("Error SampleCreate");
short[] data = new short[128]; // data buffer
for (int i = 0; i < 1024; i++)
  data[i] = (short)(32767.0 * Math.Sin(i * 6.283185 / 64)); // sine wave
if(!Bass.BASS_SampleSetData(sample, data))
  ShowMes("Error SampleSetData");
Console.Read();
What do I need to do to get the sound on my laptop speakers?  The project has attached.

saga

  • Posts: 2506
Re: Sound Card Based Signal Generator (Bass.Net)
« Reply #2 on: 15 May '21 - 20:39 »
After creating the sample, you need to create a playback channel for it (look into BASS_SampleGetChannel), and then play that channel (look into BASS_ChannelPlay).

tumanovalex

  • Posts: 17
Re: Sound Card Based Signal Generator (Bass.Net)
« Reply #3 on: 15 May '21 - 20:57 »
Thank you very much, the sound is playing!