[bb] WAV Examiner by schilcote [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:40

Previous topic - Next topic

BlitzBot

Title : WAV Examiner
Author : schilcote
Posted : 1+ years ago

Description : I wrote this to help me understand the WAV format. They're incredibly simple, in fact. All a .WAV file is is a long series of integers representing the amplitude (voltage running to speakers) of the wave at any given point. Simple, isn't it?

Code :
Code (blitzbasic) Select
file$=RequestFile$("Choose a WAV file","wav",False)

Graphics 800,600

fil=OpenFile(file$)

While Not Eof(fil)

num=ReadInt(fil)
Print num
oldy=y
y=num/10000000+200
Plot (x,y)
Line(x-1,oldy,x,y)
Flip

x=x+1
If x>800 Then
Cls
x=0
EndIf

Wend
 


WaitKey
End


Comments :


mpmxyz(Posted 1+ years ago)

 That's not right.RIFF WAVE is an audio container format. (in a media container format)It is possible - although rarely done - to compress the audio data of a *.wav file. (It is also possible to use the "mp3 compression".)But even if your file is uncompressed your code doesn't work correctly, because most audio files use 8 or 16 bit per sample - you read 32 bits at once - and because every *.wav file has got a header. (You start reading at the first byte.)


*(Posted 1+ years ago)

 Where is the check for quality etc, as has been said the header is the key to everything without it your just reading a binary file.


schilcote(Posted 1+ years ago)

 Well, I was reading from a random PCM .wav file that I had lying around. The basic idea is just to show how the PCM format was represented.


Heliotrope(Posted 1+ years ago)

 What does requestfile$ () do?


mv333(Posted 1+ years ago)

 <div class="quote"> What does requestfile$ () do? </div>It's not used in blitz3d.