Fórum Som usando BASS ou outro componente #275256
02/04/2005
0
Estou precisando fazer uma aplicação que ao conectar uma fonte de áudio na porta LineIN da placa de som, quando selecionar essa porta em um Combo e apertar um botão, o som q esta chegando toque nas caixas de som, em tempo real. Consigo com o BASS mostrar as portas disponíveis com o código abaixo (Somente me interessa o LineIN e o Aux, por isso descarto as outras), mas n consigo fazer passar o audio em tempo real, somente gravando, alguem sabe como posso ativar e dasativar a porta LineIN com um botão???? Outra dúvida, preciso q a aplicação ´ouça´ o q esta vindo pela placa e faça uma contagem em uma variável ´cont´ toda vez q o volume do som q esta entrando pela placa ultrapasse um volume pré-determinado. Espero q alguém me ajude, preciso muito disso!!!!!
Obrigado!!!
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
dName: PChar;
begin
if BASS_GetVersion <> DWord(MAKELONG(2,1)) then
begin
MessageDlg(´BASS version 2.1 was not loaded!´, mtError, [mbOk], 0);
Halt;
end;
if (not BASS_RecordInit(0)) or (not BASS_Init(1, 44100, 0, Handle, nil)) then
begin
BASS_RecordFree;
BASS_Free();
MessageDlg(´Cannot start default recording device!´, mtError, [mbOk], 0);
Halt;
end;
WaveStream := TMemoryStream.Create;
i := 0;
dName := BASS_RecordGetInputName(i);
while dName <> nil do
begin
if (dName = ´Line In´) or (dName = ´Aux´) then
ComboBox1.Items.Add(StrPas(dName));
// is this one currently ´on´?
if (BASS_RecordGetInput(i) and BASS_INPUT_OFF) = 0 then
ComboBox1.ItemIndex := i;
Inc(i);
dName := BASS_RecordGetInputName(i);
end;
ComboBox1Change(Self);// display info
end;
procedure TForm1.UpdateInputInfo;
var
i: DWord;
begin
i := BASS_RecordGetInput(ComboBox1.ItemIndex);
//TrackBar1.Position := LoWord(i);// set the level slider
case (i and BASS_INPUT_TYPE_MASK) of
BASS_INPUT_TYPE_DIGITAL: Label1.Caption := ´digital´;
BASS_INPUT_TYPE_LINE: Label1.Caption := ´line-in´;
BASS_INPUT_TYPE_MIC: Label1.Caption := ´microphone´;
BASS_INPUT_TYPE_SYNTH: Label1.Caption := ´midi synth´;
BASS_INPUT_TYPE_CD: Label1.Caption := ´analog cd´;
BASS_INPUT_TYPE_PHONE: Label1.Caption := ´telephone´;
BASS_INPUT_TYPE_SPEAKER: Label1.Caption := ´pc speaker´;
BASS_INPUT_TYPE_WAVE: Label1.Caption := ´wave/pcm´;
BASS_INPUT_TYPE_AUX: Label1.Caption := ´aux´;
BASS_INPUT_TYPE_ANALOG: Label1.Caption := ´analog´;
else
Label1.Caption := ´undefined´;
end;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
var
i: Integer;
r: Boolean;
begin
// enable the selected input
r := True;
i := 0;
// first disable all inputs, then...
while r do
begin
r := BASS_RecordSetInput(i, BASS_INPUT_OFF);
Inc(i);
end;
// ...enable the selected.
BASS_RecordSetInput(ComboBox1.ItemIndex, BASS_INPUT_ON);
UpdateInputInfo; // update info
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
WaveStream.Free;
BASS_RecordFree;
BASS_Free;
BASS_Stop;
end;
Obrigado!!!
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
dName: PChar;
begin
if BASS_GetVersion <> DWord(MAKELONG(2,1)) then
begin
MessageDlg(´BASS version 2.1 was not loaded!´, mtError, [mbOk], 0);
Halt;
end;
if (not BASS_RecordInit(0)) or (not BASS_Init(1, 44100, 0, Handle, nil)) then
begin
BASS_RecordFree;
BASS_Free();
MessageDlg(´Cannot start default recording device!´, mtError, [mbOk], 0);
Halt;
end;
WaveStream := TMemoryStream.Create;
i := 0;
dName := BASS_RecordGetInputName(i);
while dName <> nil do
begin
if (dName = ´Line In´) or (dName = ´Aux´) then
ComboBox1.Items.Add(StrPas(dName));
// is this one currently ´on´?
if (BASS_RecordGetInput(i) and BASS_INPUT_OFF) = 0 then
ComboBox1.ItemIndex := i;
Inc(i);
dName := BASS_RecordGetInputName(i);
end;
ComboBox1Change(Self);// display info
end;
procedure TForm1.UpdateInputInfo;
var
i: DWord;
begin
i := BASS_RecordGetInput(ComboBox1.ItemIndex);
//TrackBar1.Position := LoWord(i);// set the level slider
case (i and BASS_INPUT_TYPE_MASK) of
BASS_INPUT_TYPE_DIGITAL: Label1.Caption := ´digital´;
BASS_INPUT_TYPE_LINE: Label1.Caption := ´line-in´;
BASS_INPUT_TYPE_MIC: Label1.Caption := ´microphone´;
BASS_INPUT_TYPE_SYNTH: Label1.Caption := ´midi synth´;
BASS_INPUT_TYPE_CD: Label1.Caption := ´analog cd´;
BASS_INPUT_TYPE_PHONE: Label1.Caption := ´telephone´;
BASS_INPUT_TYPE_SPEAKER: Label1.Caption := ´pc speaker´;
BASS_INPUT_TYPE_WAVE: Label1.Caption := ´wave/pcm´;
BASS_INPUT_TYPE_AUX: Label1.Caption := ´aux´;
BASS_INPUT_TYPE_ANALOG: Label1.Caption := ´analog´;
else
Label1.Caption := ´undefined´;
end;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
var
i: Integer;
r: Boolean;
begin
// enable the selected input
r := True;
i := 0;
// first disable all inputs, then...
while r do
begin
r := BASS_RecordSetInput(i, BASS_INPUT_OFF);
Inc(i);
end;
// ...enable the selected.
BASS_RecordSetInput(ComboBox1.ItemIndex, BASS_INPUT_ON);
UpdateInputInfo; // update info
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
WaveStream.Free;
BASS_RecordFree;
BASS_Free;
BASS_Stop;
end;
Dudasm
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)