Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 12-08-2006
Avatar de walito
walito walito is offline
Miembro
 
Registrado: jun 2005
Posts: 121
Poder: 19
walito Va por buen camino
blade enc + delphi

hola gente.
Estoy tratando de grabar desde PCM a MP3 usando la DLL de blade.

Resulta que anda mas o menos, es decir me graba en el mp3 pero cuando lo escucho es como si fueran ardillitas , es decir el audio esta muy rapido y la verdad que ya no se q modificar!

Les pego el codigo aca para que me den una mano y de paso ya queda aca para alguien mas que lo necesite.

Por favor

Gracias

Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, mmsystem, msacm, bladedll;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    Device: HWAVEIN;
    waveIn: array [0..6999] of Byte;
    waveHeader: WAVEHDR;
    WaveInOK, BladeOK: Boolean;
    Cont: integer;
    BeConfig: TBEConfig;
    Mp3Buffer, RawBuffer: pointer;
    mp3bufferSize, NumSamples: DWORD;
    BladeHandle: THbeStream;
    Mp3File: TFileStream;
    procedure WaveInCallBack(var Msg: TMessage); message MM_WIM_DATA;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  waveFormat: tWAVEFORMATEX;
  Result: MMRESULT;
  Err: TBeErr;
  resultado: integer;
begin
    waveFormat.wFormatTag := WAVE_FORMAT_PCM; //WAVE_FORMAT_PCM
    waveFormat.nChannels := 2;
    waveFormat.nSamplesPerSec := 44100;
    waveFormat.wBitsPerSample := 16;
    waveFormat.nBlockAlign := 4;
    waveFormat.nAvgBytesPerSec := 4 * 44100;
    waveFormat.cbSize := 0;

    Result := 0;

    if Result = 0 then
    begin
        //showmessage('acmFormatChoose OK');
        WaveInOK := true;
        {* WaveIn *}
        if waveInOpen(@Device, WAVE_MAPPER, @waveFormat, Form1.handle,0,CALLBACK_WINDOW) = MMSYSERR_NOERROR then
        begin
            //showmessage('waveInOpen OK');
            waveHeader.lpData := @waveIn;
            waveHeader.dwBufferLength := sizeof(waveIn);


            if waveInPrepareHeader(Device, @waveHeader, sizeof(TWAVEHDR)) <> MMSYSERR_NOERROR then
            begin
                //showmessage('waveInPrepareHeader ERROR');
                waveInReset(Device);
                waveInClose(Device);
                exit;
            end;

            if waveInAddBuffer(Device, @waveHeader, sizeof(TWAVEHDR)) <> MMSYSERR_NOERROR then
            begin
                //showmessage('waveInAddBuffer ERROR');
                waveInReset(Device);
                waveInClose(Device);
                exit;
            end;

            if waveInStart(Device) <> MMSYSERR_NOERROR then
            begin
                //showmessage('waveInStart ERROR');
                waveInReset(Device);
                waveInClose(Device);
                exit;
            end;
        end
        else
            showmessage('waveInOpen ERROR');
        {* Fin WaveIn *}
    end
    else
        showmessage('ERROR');


    if WaveInOK then
    begin
        Mp3Buffer := nil;

        Mp3File := TFileStream.Create('xxx.mp3',fmCreate or fmShareDenyNone);

        FillChar(BeConfig,SizeOf(BeConfig),#0);
        With BeConfig.Format do begin
          dwConfig := BE_CONFIG_MP3; //BE_CONFIG_MP3;
          mp3.dwSampleRate := 44100;
          mp3.byMode := BE_MP3_MODE_STEREO;
          mp3.wBitrate := 128;
          mp3.bPrivate := False;
          mp3.bCRC     := false;
          mp3.bCopyright := False;
          mp3.bOriginal := False;
        end;

        Err := BeInitStream(BeConfig, NumSamples, Mp3BufferSize, BladeHandle);
        if Err <> BE_ERR_SUCCESSFUL then
        begin
          BladeOK := false;
          MessageDlg('Error opening encoding stream '+IntToStr(Err),MtError,[MbOk],0);
          Exit;
        end;

        BladeOK := true;

        GetMem(Mp3Buffer,mp3BufferSize);
        //GetMem(RawBuffer,NumSamples);
    end;


end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
    if WaveInOK then
    begin
        waveInReset(Device);
        waveInClose(Device);
    end;

    if BladeOK then
    begin
        BladeOK := false;
        FreeMem(Mp3Buffer);
       // FreeMem(RawBuffer);
        beCloseStream(BladeHandle);
        Mp3File.Free;
    end;

end;

procedure TForm1.WaveInCallBack(var Msg: TMessage);
var
  hdr: PWaveHdr;
  Pasadas: integer;
  Err: TBeErr;
  toWrite: DWORD;
begin
    waveHeader.lpData := @waveIn;
    waveHeader.dwBufferLength := sizeof(waveIn);

    waveInPrepareHeader(Device, @waveHeader, sizeof(TWAVEHDR));
    waveInAddBuffer(Device, @waveHeader, sizeof(TWAVEHDR));

    {* Aca va el codigo para grabar *}

    Label1.Caption := inttostr(Cont);
    inc(Cont);

    hdr := PWaveHdr(Msg.LParam);

    if BladeOK then
    begin
        Err := beEncodeChunk(BladeHandle,hdr.dwBytesRecorded, pointer(hdr.lpdata), mp3Buffer, toWrite);
        if Err <> BE_ERR_SUCCESSFUL then begin
          Label2.Caption := 'beEncodeChunk failed '+IntToStr(Err);
          BladeOK := false;
        end;
        mp3File.Write(mp3buffer^,ToWrite);
    end;

    {*******************************************}

    waveInUnPrepareHeader(Device,hdr,sizeof(TWAVEHDR));
end;

procedure TForm1.Button2Click(Sender: TObject);
var
    Version : TBeVersion; 
begin
    beVersion(Version);
    ShowMessage(
    'BladeEnc DLL version : '+IntToStr(Version.byDLLMajorVersion)+'.'+IntToStr(Version.byDLLMinorVersion)+#13+
    'BladeEnc version : '+IntToStr(Version.byMajorVersion)+'.'+IntToStr(Version.byMinorVersion)+#13+
    'BladeEnc date : '+IntToStr(Version.byDay)+'-'+IntToStr(Version.byMonth)+'/'+IntToStr(Version.wYear)+#13+
    'BladeEnc Homepage : '+Version.zHomepage);
end;

end.

Última edición por walito fecha: 12-08-2006 a las 21:13:07.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Consulta Delphi 6, Delphi 2005 y Delphi 2006 Leviatan Varios 6 18-08-2007 16:02:08


La franja horaria es GMT +2. Ahora son las 13:03:29.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi