User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 455,985 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,795 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser: Programming Forums
Views: 1284 | Replies: 2
Reply
Join Date: Dec 2007
Posts: 2
Reputation: delphinew is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
delphinew delphinew is offline Offline
Newbie Poster

write wav

  #1  
Dec 2nd, 2007
Please...i ask helping from..all ....
i want to write sound value from dinamic array,,to save in .wav type...
i tried to write header .wav and result it i think is true...
but i still confused how way to write sound value..
i put sound value in array, name is hasil_wav,,,
i take example i want write for wav 16 bit mono in DELPHI 7.0
please help me....

my listing like this...

procedure TForm1.Button4Click(Sender: TObject);
var
// chan, frq, vl : DWORD; Tmp: Integer;
// buf : array [0..10000] of BYTE;
// BytesRead : integer;
temp : string;
i : longint;
RecStream : TFileStream;
nChannels : Word; // number of channels (i.e. mono, stereo, etc.)
nSamplesPerSec : DWORD; // sample rate
nAvgBytesPerSec : DWORD; // transfer rata-rata per detik
nBlockAlign : Word;
wBitsPerSample : Word; // number of bits per sample of mono data
// FileName : String;
begin
nChannels := 1;
wBitsPerSample := 16;
nBlockAlign := nChannels * wBitsPerSample div 8;
//BASS_ChannelGetAttributes(chan, frq, vl, Tmp);
nSamplesPerSec := 22050;
nAvgBytesPerSec := nSamplesPerSec * nBlockAlign;

// FileName := ExtractFileName(SourceFileName);
// FileName := Copy(FileName, 1, Length(FileName) - Length(ExtractFileExt(FileName)));
// RecStream := TFileStream.Create(OutPath + FileName + '.wav', fmCreate);
RecStream := TFileStream.Create('Cinta.wav',fmCreate);

// Write header portion of wave file
temp := 'RIFF';
RecStream.write(temp[1], length(temp));
temp := #0#0#0#0;
RecStream.write(temp[1], length(temp)); // File size: to be updated
temp := 'WAVE';
RecStream.write(temp[1], length(temp));
temp := 'fmt ';
RecStream.write(temp[1], length(temp));
temp := #$10#0#0#0;
RecStream.write(temp[1], length(temp)); // Fixed
temp := #1#0;
RecStream.write(temp[1], length(temp)); // PCM format
if nChannels = 1 then
temp := #1#0
else
temp := #2#0;
RecStream.write(temp[1], length(temp));
RecStream.write(nSamplesPerSec, 2);
temp := #0#0;
RecStream.write(temp[1], length(temp)); // SampleRate is given as dWord
RecStream.write(nAvgBytesPerSec, 4);
RecStream.write(nBlockAlign, 2);
RecStream.write(wBitsPerSample, 2);
temp := 'data';
RecStream.write(temp[1],length(temp));
temp := #0#0#0#0;
RecStream.write(temp[1],length(temp)); // Data size: to be updated
// RecStream.Write(buf, SizeOf(Buf));

{complete WAV header
Rewrite some fields of header }
i := RecStream.Size - 8; // size of file
RecStream.Position := 4;
RecStream.write(i, 4);
i := i - $24; // size of data
RecStream.Position := 40;
RecStream.write(i, 4);
RecStream.Free;
end;
Last edited by delphinew : Dec 2nd, 2007 at 11:01 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2007
Posts: 2
Reputation: delphinew is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
delphinew delphinew is offline Offline
Newbie Poster

Re: write wav

  #2  
Dec 3rd, 2007
PLease...
I very need help from your all...
to solve my problem....
Reply With Quote  
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation: Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold 
Rep Power: 13
Solved Threads: 193
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: write wav

  #3  
Dec 4th, 2007
I've never needed to play with wav files myself, so I know nothing about it.

However, you could easily have googled this.

Hope this helps.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Pascal and Delphi Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Pascal and Delphi Forum

All times are GMT -4. The time now is 9:27 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC