Thema: Delphi Sound-Komponente

Einzelnen Beitrag anzeigen

Sämy

Registriert seit: 4. Nov 2004
Ort: Basel (CH)
76 Beiträge
 
Delphi 2007 Professional
 
#5

Re: Sound-Komponente

  Alt 5. Sep 2005, 14:50
hab das mal gemacht. nicht genau so, aber kannst ja mal schauen, was du daraus brauchen kannst. (weiss nicht, ob ich dir alles kopiert habe, sonst fragst einfach nach...). ah und du brauchst noch die bass.dll und die zugehörige unit.

Delphi-Quellcode:
const
  PEEKSPERSEC = 15;
  DATALENGTH = 2048;

type
  TWaveData = array [0..DATALENGTH - 1] of DWORD;

var
  channel: DWORD;
  x: integer;
  y: integer;
  w: TWaveData;
begin
    channel := BASS_StreamCreateFile(FALSE, PChar(FSongFile), 0, 0, BASS_STREAM_DECODE);

    FSonginfo.Bytes := BASS_StreamGetLength(channel);
    FSonginfo.Seconds := BASS_ChannelBytes2Seconds(channel, FSonginfo.Bytes);

    BASS_ChannelGetInfo(channel, FSonginfo.info);
    z := FSonginfo.Info.freq div PEEKSPERSEC;

    if BASS_ChannelIsActive(Channel) = BASS_ACTIVE_PLAYING then
      SetLength(FWaveData, Ceil(FSonginfo.Seconds * PEEKSPERSEC));

    for x := 0 to High(w) do
      w[x] := 0;

    x := 0;
    y := 0;
    while BASS_ChannelIsActive(Channel) = BASS_ACTIVE_PLAYING do
    begin
      IntToStr(BASS_ChannelGetData(Channel, @w, DATALENGTH * 4));

      if ((((x + 1) * DATALENGTH) mod z) < DATALENGTH) then
      begin
        if y > High(FWaveData) then
          break;
        FWaveData[y] := w[((x + 1) * DATALENGTH) mod z];
        Inc(y);
      end;
      Inc(x);
    end;
end;
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
  Mit Zitat antworten Zitat