24 May '13 - 04:02 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: get peake at exclusive mode at basswasap ?  (Read 612 times)
tomas.knoll
Posts: 10


« on: 25 May '12 - 10:07 »
Reply with quoteQuote

hello,
i remake my application to basswasapi at exclusive mode. Is there option to get peak level of channel ?
i try to BASS_WASAPI_GetDeviceLevel. It return 0.  (yes,  i try set BASS_WASAPI_BUFFER flag)

I have data buffer from mic, at RecordWasapiProc( buffer: pointer; length: dword )...
Is there any method how detect any voice ?
I know one solution, create new channel and feeed it by data from RecordWasapiProc... and use BASS BASS_ChannelGetLevel... Is it right decision, or there is any beth method ? i need only VOX  (voice activation control).

Second question is: Is it albe to initialize 2 sound card at one application ?
for swing between it use (BASS_WASAPI_SetDevice ?) My big problem is that i canot detect what device calls inside
recording procedure CALLBACK WASAPIPROC.

thank you,
Tomas

Logged
Ian @ un4seen
Administrator
Posts: 15270


« Reply #1 on: 25 May '12 - 12:55 »
Reply with quoteQuote

I have data buffer from mic, at RecordWasapiProc( buffer: pointer; length: dword )...
Is there any method how detect any voice ?
I know one solution, create new channel and feeed it by data from RecordWasapiProc... and use BASS BASS_ChannelGetLevel... Is it right decision, or there is any beth method ? i need only VOX  (voice activation control).

You could indeed feed the data to a push stream (via BASS_StreamPutData) and get the peak level back from BASS_ChannelGetLevel, but another option is to check the data directly yourself, something like this...

DWORD CALLBACK WasapiProc(void *buffer, DWORD length, void *user)
{
float *s=(float*)buffer;
float peak=0;
for (int a=0; a<length/sizeof(float); a++) {
if (peak<fabs(s[a])) peak=fabs(s[a]);
}
// do something with the peak information here
}

Second question is: Is it albe to initialize 2 sound card at one application ?
for swing between it use (BASS_WASAPI_SetDevice ?) My big problem is that i canot detect what device calls inside
recording procedure CALLBACK WASAPIPROC.

Yes, you can use multiple devices simultaneously. You can use BASS_WASAPI_GetDevice in a WASAPIPROC function to detect which device it is dealing with.
Logged
tomas.knoll
Posts: 10


« Reply #2 on: 28 May '12 - 12:48 »
Reply with quoteQuote

thank you,

finally i translate your code to Delphi ... I post it for Delphi users... here it is:


function GetMircophonePeak: float
var sample: ^float;
    a: integer;
    numSamples: longint;
    MicrophoneLevel: float;
begin
 MicrophoneLevel := 0;
 sample:=buffer;
 numSamples :=length div sizeof(float)-1;
 
 for a := 0 to numSamples do
    begin
    if sample^>MicrophoneLevel then
        begin
        MicrophoneLevel:= sample^;
        end;
    inc( sample ); // to next item in buffer
    end;

 GetMircophonePeak := MicrophoneLevel;
end;



tomas
Logged
tomas.knoll
Posts: 10


« Reply #3 on: 20 Jun '12 - 08:23 »
Reply with quoteQuote

hello,

finally i use BASS_WASAPI_GetDevice in a WASAPIPROC function,
but it crash after few hours of nonstop run.
I added try...except block at each command at WASAPRI PROC and
it crash at BASS_WASAPI_GetDevice.

My idea was, that you create one thread for each device, so I add
CriticalSection for inside WASAPIRECORDPROC, but it still crashed.
It did not return error code, it crash application.

Any idea what may be wrong ?

Tomas
Logged
Ian @ un4seen
Administrator
Posts: 15270


« Reply #4 on: 20 Jun '12 - 13:55 »
Reply with quoteQuote

That's strange. I'll send you a debug version to confirm what's happening.
Logged
tomas
Guest
« Reply #5 on: 25 Jun '12 - 13:54 »
Reply with quoteQuote

hello,

i try to locate problem at application. It crashed for consume all Stack memory.

but, problem is that it happen when i add this 2 lines of code...
 BASS_WASAPI_Init(-1,48000,2, flag,0.05,0.005,@PlaybackWasapiProc,nil);
 BASS_WASAPI_Start();

method PlaybackWasapiProc i let empty for demonstrating only..
When i initialize likethis : BASS_WASAPI_Init(-1,48000,2, flag,0.05,0.005,nil,nil);
nil at delphi = NULL, there is no problem with stack overflow.

I add code for playback wasapi proc...

function PlaybackWasapiProc( buffer: pointer; length: dword ): dword; stdcall;
begin
end;

Application consume about 4KBytesc per 3 second blocks.. I see it at Proccess Manager,
after hour it crash...
Tomas
Logged
tomas
Guest
« Reply #6 on: 25 Jun '12 - 14:01 »
Reply with quoteQuote

finaly may be I search problem...

My old declaration of method

function PlaybackWasapiProc(buffer:Pointer; length:DWORD): DWORD; stdcall;

new declaration is:
 function PlaybackWasapiProc(buffer:Pointer; length:DWORD; user:Pointer): DWORD; stdcall;

Tomas
Logged
tomas.knoll
Posts: 10


« Reply #7 on: 28 Jun '12 - 06:48 »
Reply with quoteQuote

Ian,
thank you for solving my problem,
your library debug version point to problem,

Tomas
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines