26 May '13 - 04:44 *
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: ASIO input monitor (Delphi 6)  (Read 5739 times)
tcr777
Guest
« on: 27 Feb '08 - 14:37 »
Reply with quoteQuote

Hi,

I want to get level from input 1. But BASS_ASIO_START return error 18 BASS_ERROR_NOCHAN. What's wrong?
Here  is my code:

if not BASS_ASIO_Init(0) then
 begin
  ShowMessage('ASIO device error');
 end;
 BASS_ASIO_SetRate(48000);
 BASS_ASIO_ChannelSetFormat(True,0,BASS_ASIO_FORMAT_FLOAT);
 BASS_ASIO_ChannelSetRate(True,0,48000);
 BASS_ASIO_ChannelSetVolume(True,0,1);
 BASS_ASIO_ChannelEnable(True,0,nil,0);
 BASS_ASIO_Start(0);

thanks
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #1 on: 28 Feb '08 - 15:38 »
Reply with quoteQuote

The problem is the "nil" BASS_ASIO_ChannelEnable "proc" parameter, which will disable the channel. You could use an empty ASIOPROC instead, and pause the channel (BASS_ASIO_ChannelPause) to avoid unnecessary processing - you will still be able to use BASS_ASIO_ChannelGetLevel to get the level then.
Logged
tcr777
Guest
« Reply #2 on: 28 Feb '08 - 20:33 »
Reply with quoteQuote

Thanks, Ian. Now it's work. But i can't get input level, Bass_Asio_ChannelGetLevel(True,0) return 0.
I can get input level from output, only if i mirroring input to output channel.
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #3 on: 29 Feb '08 - 17:42 »
Reply with quoteQuote

That's strange. I just checked, and it seemed to be ok. With the channel unpaused, do you receive non-0 data in your ASIOPROC?
Logged
tcr777
Guest
« Reply #4 on: 29 Feb '08 - 21:06 »
Reply with quoteQuote

Here is my code

ASIORecProc:
Lev1:=BASS_ASIO_ChannelGetLevel(True,0);
 Lev2:=BASS_ASIO_ChannelGetLevel(True,1);
 if Lev1<>0 then Form1.VU1.Progress:=Trunc(20*log10(Lev1)) else Form1.VU1.Progress:=-70;
 if Lev2<>0 then Form1.VU2.Progress:=Trunc(20*log10(Lev2)) else Form1.VU2.Progress:=-70;

startup
if not bass_asio_init(0) then
 begin
  ShowMessage('Can''t init ASIO Device. Error #'+IntToStr(BASS_ASIO_ErrorGetCode()));
 end;
 BASS_ASIO_SetRate(48000);

 BASS_ASIO_ChannelEnableMirror(0,True,0);
 BASS_ASIO_ChannelEnableMirror(1,True,1);

 BASS_ASIO_ChannelEnable(True,0,@asiorecproc,0);
 BASS_ASIO_ChannelEnable(True,1,@asiorecproc,0);

 BASS_ASIO_ChannelSetFormat(True,0,BASS_ASIO_FORMAT_FLOAT);
 BASS_ASIO_ChannelSetFormat(True,1,BASS_ASIO_FORMAT_FLOAT);

 BASS_ASIO_ChannelSetVolume(True,0,1);
 BASS_ASIO_ChannelSetVolume(True,1,1);

 BASS_ASIO_ChannelSetRate(True,0,48000);
 BASS_ASIO_ChannelSetRate(True,1,48000);

 BASS_ASIO_ChannelPause(True,0);
 BASS_ASIO_ChannelPause(True,1);

 if not BASS_ASIO_Start(0) then ShowMessage('ASIOStart Error');

checkbox click event:

if Mon1.Checked then BASS_ASIO_ChannelReset(True,0,BASS_ASIO_RESET_PAUSE)
 else BASS_ASIO_ChannelPause(True,0);

p.s.
What's the best method to get level: on timer or asioproc?
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #5 on: 2 Mar '08 - 17:13 »
Reply with quoteQuote

The BASS_ASIO_ChannelGetLevel calls should be in a timer. When a channel is paused, its ASIOPROC won't be called.
Logged
tcr77
Guest
« Reply #6 on: 3 Mar '08 - 12:21 »
Reply with quoteQuote

Thanks. Still can't get channel level. BASS_ASIO_ErrorGetCode() return #9.
BASS_ERROR_START, but bass_asio_start return true. Can you give me for example some
working code?
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #7 on: 3 Mar '08 - 12:47 »
Reply with quoteQuote

Assuming BASS_ASIO_Start was successful, BASS_ERROR_START means that the channel isn't enabled. Are you sure the BASS_ASIO_ChannelEnable call(s) succeeded? What does BASS_ASIO_ChannelIsActive say about it?
Logged
tcr777
Guest
« Reply #8 on: 3 Mar '08 - 14:46 »
Reply with quoteQuote

Yes! Another code:
procedure TForm1.FormCreate(Sender: TObject);
var chan_info:BASS_ASIO_CHANNELINFO;
begin
 if not BASS_ASIO_Init(0) then
 begin
 ShowMessage('ASIO Init error');
 end;
 BASS_ASIO_ChannelEnable(True, 0, @AsioProc, 0);
 BASS_ASIO_SetRate(48000);
 BASS_ASIO_ChannelSetFormat(True, 0, BASS_ASIO_FORMAT_FLOAT);
 BASS_ASIO_ChannelGetInfo(True,0,chan_info);
 if chan_info.format=BASS_ASIO_FORMAT_24BIT then ShowMessage('BASS_ASIO_FORMAT_24BIT');
 BASS_ASIO_Start(0);
 if BASS_ASIO_ChannelIsActive(True,0)=BASS_ASIO_ACTIVE_ENABLED then ShowMessage('channel enabled');
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var level:float;
begin
 level:=BASS_ASIO_ChannelGetLevel(True,0);
 Label1.Caption:=IntToStr(BASS_ASIO_ErrorGetCode());
 if level<>0 then db:=20*log10(level);
end;

Function AsioProc(input: BOOL; channel: DWORD; buffer: Pointer; length, user: DWORD): DWORD; stdcall;
begin
end;

i got message BASS_ASIO_FORMAT_24BIT and channel enabled
label1.caption is 9
then i change input channel to output  it works ok.
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #9 on: 5 Mar '08 - 15:41 »
Reply with quoteQuote

BASS_ASIO_ChannelIsActive will return BASS_ASIO_ACTIVE_ENABLED if the channel is enabled, regardless of whether the device has been started. So please also check the BASS_ASIO_Start return value.
Logged
tcr777
Guest
« Reply #10 on: 7 Mar '08 - 07:28 »
Reply with quoteQuote

Bass_Asio_Start  return True.
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #11 on: 7 Mar '08 - 15:33 »
Reply with quoteQuote

OK. So in summary... BASS_ASIO_Start returns TRUE, BASS_ASIO_ChannelIsActive returns BASS_ASIO_ACTIVE_ENABLED and BASS_ASIO_ChannelGetLevel returns -1 (error code BASS_ERROR_START). Is that correct?

Actually, I did notice a little bug in BASS_ASIO_ChannelGetLevel that would sometimes make it return 0 instead of -1 on an error. Maybe that caused some confusion. A corrected DLL is in the BASSASIO download now.
Logged
tcr777
Guest
« Reply #12 on: 7 Mar '08 - 22:36 »
Reply with quoteQuote

Correct. With new DLL, result is the same.
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #13 on: 8 Mar '08 - 13:40 »
Reply with quoteQuote

That is very strange, as the only way I can see a BASS_ERROR_START error occurring is if the device hasn't been started or if the channel wasn't enabled at the time the device was started.

To confirm whether the channel was actually started, is your AsioProc being called? (make sure it isn't paused)
Logged
tcr777
Guest
« Reply #14 on: 11 Mar '08 - 09:39 »
Reply with quoteQuote

Yes, it's called. it's sad.  i want  to get level of channel, without  sound. is there another way to make it?
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #15 on: 11 Mar '08 - 12:41 »
Reply with quoteQuote

Yes, it's called.

In that case, I can see no reason for the BASS_ERROR_START error. I think I will have to send you a debug version to find out what is happening there (please confirm your email address).
Logged
tcr777
Guest
« Reply #16 on: 11 Mar '08 - 13:59 »
Reply with quoteQuote

Yes, please send it to this address.
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #17 on: 13 Mar '08 - 17:27 »
Reply with quoteQuote

For anyone else having this problem, it was caused by BASS_ASIO_ChannelGetLevel expecting the "input" parameter to be 0 or 1, while the Delphi "True" is -1. A BASSASIO update is up now, in which it will accept any non-0 value to be "true".
Logged
JacekH
Posts: 24


« Reply #18 on: 17 Mar '08 - 10:42 »
Reply with quoteQuote

For anyone else having this problem, it was caused by BASS_ASIO_ChannelGetLevel expecting the "input" parameter to be 0 or 1, while the Delphi "True" is -1. A BASSASIO update is up now, in which it will accept any non-0 value to be "true".

In Delphi:
A Boolean type is stored as a Byte, a ByteBool is stored as a Byte, a WordBool type is stored as a Word, and a LongBool is stored as a Longint.
A Boolean can assume the values 0 (False) and 1 (True). ByteBool, WordBool, and LongBool types can assume the values 0 (False) or nonzero (True).

Regards,
Jacek
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines