473,508 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Merge Two Wave Files using php

5 New Member
Hi Guys

I need a php script which will merge two wave files as i have already done a script which will will join the two wave files and play one after the other, can anyone advice me how to merge the two wave file and the two files has to play simultaneously. i have placed my script here


<?php

$content = joinwavs(array('1.wav','2.wav'));
header('Content-Type: audio/x-wav');
//echo $content;



function joinwavs($wavs){
$fields = join('/',array( 'H8ChunkID', 'VChunkSize', 'H8Format',
'H8Subchunk1ID', 'VSubchunk1Size',
'vAudioFormat', 'vNumChannels', 'VSampleRate',
'VByteRate', 'vBlockAlign', 'vBitsPerSample' ));
$data = '';

foreach($wavs as $wav){
$fp = fopen($wav,'rb');
$header = fread($fp,36);
$info = unpack($fields,$header);
// Destination file to be writed
$destfile = "destination.wav";
// read optional extra stuff
if($info['Subchunk1Size'] > 16){
$header .= fread($fp,($info['Subchunk1Size']-16));
}
// read SubChunk2ID
$header .= fread($fp,4);
// read Subchunk2Size
$size = unpack('vsize',fread($fp,4));
$size = $size['size'];
// read data
$data .= fread($fp,$size);
$filecontent = $header.pack('V',strlen($data)).$data;
// Write the output data in a seperate file
$fp1 = fopen($destfile,"wb");
fwrite($fp1,$filecontent);
fclose($fp1);


}
}

?>





Regards

Karthik
Apr 25 '07 #1
3 5401
Motoma
3,237 Recognized Expert Specialist
This is getting more into the area of programming that PHP is not designed for. You will need to examine the WAV standard and see exactly how two overlapped WAV files are represented as data. My assumption is that you will first need to read in each segment of data from each WAV file and perform a sort of "data merge" on the waveform, and then produce a new file using your new data set.

You will probably have better luck finding a tool that will do this for you.
Apr 25 '07 #2
tolkienarda
316 Contributor
just as a brief suggestion of a language that would work is python. it is so versitle i an still a total beginer but the more i learn the more i love the language and its odd rules.

eric
Apr 25 '07 #3
rajasekar.karthik
5 New Member
This is getting more into the area of programming that PHP is not designed for. You will need to examine the WAV standard and see exactly how two overlapped WAV files are represented as data. My assumption is that you will first need to read in each segment of data from each WAV file and perform a sort of "data merge" on the waveform, and then produce a new file using your new data set.

You will probably have better luck finding a tool that will do this for you.

Is there any third party tool to do this , if so can u mention some of the tools that should work in linux server.
May 7 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3208
by: vikram | last post by:
in a stereo type of wave file i want to know what is this left & right info in a wave file??? how do i read the left & right info from a .wav file to a buffer..
8
9494
by: Squirrel | last post by:
Hi everyone, I've created a mail merge Word doc. (using Office XP) , the data source is an Access query. Functionality I'm attempting to set up is: User sets a boolean field to true for...
9
4310
by: Neil Ginsberg | last post by:
I have a strange situation using Access to automate a Word mail merge. Using Access 2000 and Word 2000, the code opens Word, opens the document in Word, sets a table in the calling Access...
5
2590
by: m.topczewski | last post by:
Hello, I'm a beginner in c++, i have to write a program that will take couple of segments from one wave file, and store them in another wave file to be played back later. Here's the code i have...
1
1698
by: blitzme | last post by:
I created a PERL script to play a wave file using Win32::Sound All went well. So then I was trying to create an executable file with the wav files bound inside it using Activestate Dev kit...
4
7214
by: Tom Jones | last post by:
I have an application that was originally built using Visual Studio 2003 that I upgraded to Visual Studio 2005. When I attempt to build the *.msi file in the deployment project, I am getting a...
7
7225
by: giladp1 | last post by:
I found Albert Kallal's great "Super easy Word Merge" code in his site at: http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html Thanks Albert so much for sharing this. I am looking...
1
14888
by: homevista | last post by:
Part II: Wave file - How to read to a buffer Wave (or Wav) is the standard format for storing audio data on the PC. As software developers, we are interested in the internal structure of the file...
6
29093
by: homevista | last post by:
PART III: Putting things together In part I we examined the modem to verify that it supported voice. If so, we took a note about the voice data format that we would use. In the second part, we...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7124
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7385
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.