pr80
asked on
Playing RAW .pcm sound files
I am writing an application that needs to play sound files in RAW .pcm format (8000khz 8bit mono a-law).
Does anyone know how I can do this in VB6
Thanks
Does anyone know how I can do this in VB6
Thanks
also just to play a WAV
this was a previously accepted answer by me do the following
ttry this
Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String,
ByVal uFlags As Long) As Long
Then to call the API type:
Variable = sndPlaySound (Location, 1)
So for example to play a .wav file located at C:\Sounds\sound.wav type:
Variable = sndPlaySound ("C:\Sounds\sound.wav, 1)
thats it
andy
but that will only play WAV's not PCM's i dont know if it matters
this was a previously accepted answer by me do the following
ttry this
Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String,
ByVal uFlags As Long) As Long
Then to call the API type:
Variable = sndPlaySound (Location, 1)
So for example to play a .wav file located at C:\Sounds\sound.wav type:
Variable = sndPlaySound ("C:\Sounds\sound.wav, 1)
thats it
andy
but that will only play WAV's not PCM's i dont know if it matters
ASKER
The files I need to play are RAW .PCM files not .WAV files and they do not play using a .WAV player
well i dont know how to then .... sorry matey, i tried. even myself as an EE expert has limitations (lol)
dont worry somebody will come with a solution im sure,
cheers
Andy
dont worry somebody will come with a solution im sure,
cheers
Andy
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Some more info about RAW PCM audio format.
PCM stands for Pulse Code Modulation and is a particular kind of sampling: the values of digital converted samples are actual values and not differences between subsequent samples. However, this is the default audio encoding system used with waw files by Windows. You should also know sampling frequency (usually from 8 to 44 kHz) and amplitude (8 or 16 bits) related to your PCM format.
About RAW file type: RAW sound files are simply stored exactly as they are in memory, e.g. an 8-bit mono RAW file consists of bytes that specify the volume of the sound. RAW FILES CONTAIN NO HEADER.
Conclusion: a RAW PCM file is the same that a WAW PCM without file header.
My personal advice is to do the following: convert RAW to WAW, play WAW (with sndPlaySound API or MMControl) and, if necessary, convert WAW to RAW. You shouldn't get loss of quality. On the web, you can find easily a lot of RAW/WAW converter. If you need, I can give you the links (other than that of the previous comment).
Regards
PCM stands for Pulse Code Modulation and is a particular kind of sampling: the values of digital converted samples are actual values and not differences between subsequent samples. However, this is the default audio encoding system used with waw files by Windows. You should also know sampling frequency (usually from 8 to 44 kHz) and amplitude (8 or 16 bits) related to your PCM format.
About RAW file type: RAW sound files are simply stored exactly as they are in memory, e.g. an 8-bit mono RAW file consists of bytes that specify the volume of the sound. RAW FILES CONTAIN NO HEADER.
Conclusion: a RAW PCM file is the same that a WAW PCM without file header.
My personal advice is to do the following: convert RAW to WAW, play WAW (with sndPlaySound API or MMControl) and, if necessary, convert WAW to RAW. You shouldn't get loss of quality. On the web, you can find easily a lot of RAW/WAW converter. If you need, I can give you the links (other than that of the previous comment).
Regards
ASKER
Thank you for your response.
The link to the RAW/WAV converter is dead.
Do you have any other links.
Thanks
The link to the RAW/WAV converter is dead.
Do you have any other links.
Thanks
ASKER
Also I must add the .pcm files are a-law format
Sorry, I wasn't able to post my comment ... I have got 3 times an internal server error at EE. I tried also to contact the CS, but it seemed that nothing was working some hours ago..
Here there are the links for you:
http://www.fmjsoft.com/awaveaudio.html
Awave Audio is a (shareware) dedicated audio file format batch converter.
Do conversions from the about 60 audio file formats that it can read into any of the 30 or so audio file formats that it writes!
supports:
.....
RAW R+W Raw signed PCM data.
....
WAV R+W Ms Windows PCM wave.
WAV R+W 'Extensible format' Microsoft Waveform file.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---
http://www.nctsoft.com/products/NCTMediaConverter/
The NCT Media Converter is a (shareware) universal converter and grabber of audio files
WAV PCM;
compressed WAV (ADPCM, GSM, DSP, A-LAW, U-LAW, ALF2 and others);
MP3 (MPEG Layer-3);
VOX (Dialogic ADPCM);
WMA (Windows Media Audio);
RAW (PCM, A-LAW, U-LAW);
CDA (Audio CD Tracks).
-------------------------- ---------- ---------- ---------- ---------- -----
http://www.audioconvert.com/
AudioConvert is a ( $ 29,95) professional solution for converting, ripping, transforming and recording all types of audio files.
Converting WAV, MP3, WMA, GSM, G.726, RAW, VOX, ACM, ADPCM, and DSP audio
-------------------------- ---------- ---------- ---------- ---------- ---------
Unfortunately I couldn't find any freeware that seemed reliable.
Notice that PCM 8 bit, mono, 8 kHz is one kind of encoding. I believe that a-Law is a different one.... so, check your file(s) property before performing the conversion.
good luck
Marco
Here there are the links for you:
http://www.fmjsoft.com/awaveaudio.html
Awave Audio is a (shareware) dedicated audio file format batch converter.
Do conversions from the about 60 audio file formats that it can read into any of the 30 or so audio file formats that it writes!
supports:
.....
RAW R+W Raw signed PCM data.
....
WAV R+W Ms Windows PCM wave.
WAV R+W 'Extensible format' Microsoft Waveform file.
--------------------------
http://www.nctsoft.com/products/NCTMediaConverter/
The NCT Media Converter is a (shareware) universal converter and grabber of audio files
WAV PCM;
compressed WAV (ADPCM, GSM, DSP, A-LAW, U-LAW, ALF2 and others);
MP3 (MPEG Layer-3);
VOX (Dialogic ADPCM);
WMA (Windows Media Audio);
RAW (PCM, A-LAW, U-LAW);
CDA (Audio CD Tracks).
--------------------------
http://www.audioconvert.com/
AudioConvert is a ( $ 29,95) professional solution for converting, ripping, transforming and recording all types of audio files.
Converting WAV, MP3, WMA, GSM, G.726, RAW, VOX, ACM, ADPCM, and DSP audio
--------------------------
Unfortunately I couldn't find any freeware that seemed reliable.
Notice that PCM 8 bit, mono, 8 kHz is one kind of encoding. I believe that a-Law is a different one.... so, check your file(s) property before performing the conversion.
good luck
Marco
Hi pr80,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept dmarco's comment(s) as an answer.
pr80, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept dmarco's comment(s) as an answer.
pr80, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
Per recommendation, force-accepted.
Netminder
CS Moderator
Netminder
CS Moderator
but have a look at this anyway
Option Explicit
Private Sub Command1_Click()
Dim FileNumber As Integer
Dim I As Single
Dim Min As Single
Dim Max As Single
Dim Temp As Integer
Dim XZoomrate As Single
Dim YZoomrate As Single
Dim LastX As Single
Dim LastY As Single
On Error GoTo ErrorHandler
' Enable Cancel error
With Picture1
CommonDialog1.CancelError = True
CommonDialog1.Filter = "Wave files (*.wav)|*.wav"
CommonDialog1.ShowOpen
' Change the caption of the form
Me.Caption = CommonDialog1.filename
I = 44 ' Set I To 44, since the wave sample is begin at Byte 44.
' Open file to get the length of the wav
'
'e file.
FileNumber = FreeFile
Open CommonDialog1.filename For Random As #FileNumber
Do
Get #FileNumber, I, Temp
I = I + 1
' Get the smallest and largest number. T
'
'hey will be use for the adjustment
' of the vertical size.
If Temp < Min Then Min = Temp
If Temp > Max Then Max = Temp
Loop Until EOF(FileNumber)
Close #FileNumber
' Adjust values and reset values
XZoomrate = (.Width / I)
YZoomrate = (Max - Min) / (.Height / 2)
.CurrentX = 100
.CurrentY = .Height / 2
LastX = 100
LastY = .Height / 2
.AutoRedraw = True
I = 44
' Reopen file using a different FileNumb
'
'er
FileNumber = FileNumber + 1
.Cls
Open CommonDialog1.filename For Random As #FileNumber
Do
Get #FileNumber, I, Temp
' Set CurrentX and CurrentY
.CurrentX = .CurrentX + XZoomrate
.CurrentY = (Temp / YZoomrate) + .Height / 2
' Plot graph
Picture1.Line (LastX, LastY)-(.CurrentX, .CurrentY), vbBlack
' Reset values
LastX = .CurrentX
LastY = .CurrentY
I = I + 1
If .CurrentX > .Width Then Exit Do
Loop Until EOF(FileNumber)
Close #FileNumber
End With
ErrorHandler:
' Do nothing
End Sub
Private Sub Form_Resize()
On Error Resume Next
' Resize control
With Picture1
.BackColor = vbWhite
.ForeColor = vbBlack
.Move 50, 500, Width - 200, Height - 800
End With
End Sub
cheers
Andy