Author Topic: Basic Newbie Question  (Read 427 times)

tplindley

  • Posts: 1
Basic Newbie Question
« on: 17 Mar '19 - 14:22 »
I am working on a Xamarin app to detect audio events. Hoping to use BASS and think I have the platform issues figured out. My issue is I have looked at the BASS doc and can't seem to find a simple sample to get started. What I would like is a method to examine in real time the input audio stream from a phone microphone and catch areas of low sound (i.e. silence) and events of high decibel sounds. I've read about 'levelmeters' and was thinking this might be a solution but have no idea where to turn to a high level outline of how to proceed.

Thanks for any information/pointers you can share.

Ian @ un4seen

  • Administrator
  • Posts: 21979
Re: Basic Newbie Question
« Reply #1 on: 18 Mar '19 - 14:41 »
To monitor the input level, you would use BASS_RecordInit and BASS_RecordStart to start capturing the sound, and then BASS_ChannelGetLevel(Ex) to get its level, eg. in a timer. The code could look something like this:

Code: [Select]
BASS_RecordInit(-1); // initialize default recording device
recording = BASS_RecordStart(44100, 1, 0, RecordProc, NULL); // start a mono recording on it

...

BOOL CALLBACK RecordProc(HRECORD handle, const void *buffer, DWORD length, void *user)
{
return TRUE; // continue recording
}

...

float level;
BASS_ChannelGetLevelEx(recording, &level, 0.05, BASS_LEVEL_MONO); // get the level of the last 50ms

Please see the documentation for details on the mentioned functions.

Tom Lindley

  • Guest
Re: Basic Newbie Question
« Reply #2 on: 19 Mar '19 - 05:59 »
Thanks for that help, got a preliminary app working and I think this will work. A couple of follow up questions.
1. The Bass.Net wrapper will not work for a UWP application, correct? Are there any plans to create a wrapper for the version used with UWP applications?
2. For native Android. I have the NuGet BASS package defined, but cannot access any of the functions. I'm assuming this is because I am using Xamarin and .Net but once again, not the .Net 4.6.1 framework. Guessing I would need a .Net wrapper for Mono?

Really appreciate the nudge, got me going in the right direction. (test app is WPF app for now, but am targeting Android and iOS)

Thanks.

Ian @ un4seen

  • Administrator
  • Posts: 21979
Re: Basic Newbie Question
« Reply #3 on: 19 Mar '19 - 17:53 »
1. The Bass.Net wrapper will not work for a UWP application, correct? Are there any plans to create a wrapper for the version used with UWP applications?

There is a separate BASS.Net version available for UWP in the WinStore thread, here:

   www.un4seen.com/forum/?topic=16665

2. For native Android. I have the NuGet BASS package defined, but cannot access any of the functions. I'm assuming this is because I am using Xamarin and .Net but once again, not the .Net 4.6.1 framework. Guessing I would need a .Net wrapper for Mono?

I'm not sure about NuGet, but there is an Android version included in the BASS.Net package that's available from the BASS webpage.