###################################################################
WAVE HEADER
Alle Details aus dem Header einer Wave Datei auslesen.
Copyright Sven Bader 2001
Dieser Quelltext ist Freeware. Bei Verwendung bitte Quelle angeben.
Kritik und Anregungen an: info@svenbader.de
Für eventuell auftretende Schäden wird keine Haftung übernommen.
###################################################################
PROC WaveHeader
    Declare b#,hz$,chan$,bits$, riff$, wave$,bytessec$,bytessample$,chunk$
    Parameters load$
    SetErrorLevel -1
    Case filesize(load$) = -1 : Break
    SetErrorLevel 0
    Dim B#,filesize(load$)
    Assign #1,load$
    OpenRW #1
    RIFF
    BlockRead(#1,b#,0,4)
    riff$ = Char$(b#,0,4)
    CHUNK LÄNGE (Header Länge?)
    BlockRead(#1,b#,0,4)
    WAVE
    BlockRead(#1,b#,0,4)
    wave$ = Char$(b#,0,4)
    FMT
    BlockRead(#1,b#,0,4)
    Chunk Länge (???)
    BlockRead(#1,b#,0,4)
    Format (0 = Mono, 1 = Stereo)
    BlockRead(#1,b#,0,2)
    Kanäle (Mono/Stereo)
    BlockRead(#1,b#,0,2)
    chan$ = Str$(Byte(b#,0))
    Frequenz in Hertz
    BlockRead(#1,b#,0,4)
    hz$ = % + MkStr$(0,(8 - Len(Bin$(Byte(b#,2))))) + Bin$(Byte(b#,2)) + MkStr$(0,(8 - Len(Bin$(Byte(b#,1))))) + Bin$(Byte(b#,1)) + MkStr$(0,(8 - Len(Bin$(Byte(b#,0))))) + Bin$(Byte(b#,0))
    hz$ = Str$(Int(Val(hz$)))
    Bytes pro Sekunde
    BlockRead(#1,b#,0,4)
    bytessec$ = % + MkStr$(0,(8 - Len(Bin$(Byte(b#,2))))) + Bin$(Byte(b#,2)) + MkStr$(0,(8 - Len(Bin$(Byte(b#,1))))) + Bin$(Byte(b#,1)) + MkStr$(0,(8 - Len(Bin$(Byte(b#,0))))) + Bin$(Byte(b#,0))
    bytessec$ = Str$(Int(Val(bytessec$)))
    Byte pro Sample
    BlockRead(#1,b#,0,2)
    bytessample$ = Str$(Byte(b#,0))
    Bits pro Sample
    BlockRead(#1,b#,0,2)
    bits$ = Str$(Byte(b#,0))
    Chunk Name
    BlockRead(#1,b#,0,4)
    Chunk Länge
    BlockRead(#1,b#,0,4)
    chunk$ = % + MkStr$(0,(8 - Len(Bin$(Byte(b#,2))))) +  Bin$(Byte(b#,2)) + MkStr$(0,(8 - Len(Bin$(Byte(b#,1))))) +  Bin$(Byte(b#,1)) + MkStr$(0,(8 -  Len(Bin$(Byte(b#,0))))) +  Bin$(Byte(b#,0))
    chunk$= Str$(int(val(chunk$)))
    Dispose b#
    print Typ:  + riff$ +   /  + wave$
    print Länge des Datenbereichs:  + chunk$ +  Bytes
    print Bytes pro Sekunde:  + bytessec$
    print Bytes pro Sample:  + bytessample$
    print Kanäle:  + chan$
    print Hetz:  + hz$
    print Bits:  + bits$
    Closerw #1
ENDPROC
WaveHeader LoadFile$(Wave Datei öffnen,Wave Datei (*.WAV)|*.WAV)
='./../../funktionsreferenzen/XProfan/waitinput/'>WaitInput