Author Topic: Visuals.DetectPeakFrequency on microphone input  (Read 71 times)


  • Posts: 1
Hello I'm doing a  DetectPeakFrequency  on my microphone input (or Default device -1).

I could do it  with an mp3  but I need help with the input of the microphone:

That works for me with the mp3 file:
Code: [Select]

 Visuals BassMiscVisuals = new Visuals();
 float energie;
 int freqs = new Int32();
 int streamchannel;

        private void button2_Click(object sender, EventArgs e)
            if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
                streamchannel = Bass.BASS_StreamCreateFile("tones.mp3", 0L, 0L, BASSFlag.BASS_DEFAULT);
                Bass.BASS_ChannelPlay(streamchannel, false);

        private void timer1_Tick(object sender, EventArgs e)
            freqs = BassMiscVisuals.DetectPeakFrequency(streamchannel, out energie);
            textBox1.Text = freqs.ToString();

What do i need to change to make it work with microphone input? I also cannot find any examples

Ian @ un4seen

  • Administrator
  • Posts: 24797
Re: Visuals.DetectPeakFrequency on microphone input
« Reply #1 on: 13 Jan '23 - 17:03 »
You should basically just need to replace the BASS_Init and BASS_StreamCreateFile calls with BASS_RecordInit and BASS_RecordStart calls. A RECORDPROC callback function also needs to be provided (to BASS_RecordStart), which can simply contain "return true" for your purpose. Please see the documentation for details on the mentioned functions.