Re: WAV functions
- Posted by Dan Moyer <DANIELMOYER at prodigy.net> May 24, 2003
- 393 views
Derek, I'm working on a vaguely related problem, *maybe* this would work: *maybe:* 1. find the "number of bits per sample" (8, 16 or 24?)(8 would be 256 bits of resolution, I think), presuming it's the same for each sample you want to mix together, so you can know what "zero" is (ie, no amplitude in the wave, flat "wave", no up/down oscillation) ; I'm assuming that for 8-bit it's 128, etc. 2. subtract the "zero" value from every sample point value, for each sample you want to mix (now allowing for negative numbers, of course); this way you have sets of values that go up & down from actual zero; 3. now add them all together, point by corresponding point; 4. find the most positive and negative value in that summed set; figure a divide-by value that would make the absolute value of the biggest of those max/min into the loudest value you want, equal to or lower than the resolution. Since the result is now zero referenced, apply that divisor to every sample point; 5. and finally, re-add the "zero" value to each point. Dan Moyer ----- Original Message ----- From: "Derek Parnell" <ddparnell at bigpond.com> To: "EUforum" <EUforum at topica.com> Sent: Thursday, May 22, 2003 7:00 PM Subject: WAV functions > > > To: Daryl van den Brink > > Do you know a good algorithm to combine two or more WAV files? > > I've written an amusement for myself. Its a little application that I can > use to write music with. It works on the principle of creating 'voice' > tracks and then combining them into the final WAV file. The current > algorithm I use sort of works, but it has the side-effect of diminishing > the volume of the sound. Also, when working with lots of tracks, some > distortions are introduced. > > In fact I've tried a few algorithms but none have really worked well. The > ones that have given me the most promising results have been ... > > a) Find the geometric mean of the corresponding sample values. > b) Find the arthimetric mean of the corresponding sample values. > c) Find the geometric mean of the absolute value of the corresponding > sample values. > > But I'm thinking that I really need to use the delta between adjacent > samples instead. I haven't tried this yet because I really don't know > enough about the subject. > > > I'd post the code but its not ready for serious reviewing yet - most is > very experimental. > > -- > > cheers, > Derek Parnell > > > > TOPICA - Start your own email discussion group. FREE! > >