Re: Lower WAV pitch problem

new topic     » goto parent     » topic index » view thread      » older message » newer message

Oh, you're still messing around with that old crappy version of WaveEdit.  
Didn't you say it crashed when the wave is displayed?  I sent you the wrong 
file that time (it was one of my "work in progress" backups).  I'll send you 
a proper working one, but it's a bit embarrasing because it sucked badly.

The code you showed looks fine to me.  It should sound exactly one octave 
lower in pitch. I don't know what you could be doing to double the duration 
and make it's pitch stay the same, but I'd love to find out.  Maybe you 
should listen to it again, because I seriously doubt that it would be the 
same pitch.  Try inserting two samples in between each soriginal sample, to 
make the wave 3 times longer.  This definitely won't sound the same.

This code has not been tested.

procedure LowerPitch()
integer diff1, diff2
sequence newWave
newWave = {}

   -- wave is the wave data, wave[1] is for mono
   for n = 1 to wavelen do
     newWave &= wave[1][n]

     if n < wavelen then
        diff1 = wave[1][n+1] - wave[1][n]
        if diff != 0 then
           newWave &= {wave[1][n] + floor(diff / 3), wave[1][n] + 
floor(diff*2 / 3)}
        else  -- two successive points are the same value, so just copy that 
value:
           newWave &= repeat(wave[1][n], 2)
        end if
     end if
   end for

   wave[1] = newWave
   wavelen = length(wave[1])

   changeStatus = 1
   refresh()

end procedure


regards,
Daryl Van Den Brink

>I'm trying to write a routine to lower the pitch of a waveform, by adding a
>new sample point between every existing point, each new point being equal 
>to
>half the value of the difference between each of the original points, but
>it's not working.
>
>I get a wav that's twice as long in duration, quieter, but sounds like 
>still
>the same pitch as the original.  If I look at the waveform using a version
>of "Cool Edit", it *looks* correctly stretched out doubly, though it 
>doesn't
>sound any
>lower; and if I use "Cool Edit" to stretch the original, that *does* sound
>lower, but *looks* the same as the original (ie, unstretched)!  And none of
>the format data appears to be any different, as far as I can see.
>
>Anybody have any idea what I might be doing wrong?
>
>What I did was, I included the following procedure into an old version of
>Daryl van den Brink's "WaveEdit":
>
>--<code begins>
>
>-- LOWER THE PITCH OF A SOUND BY 1/2:
>
>-- copy first point in sample to a second, new sequence;
>
>-- then, for every point in the original for which there is a next point,
>-- subtract value of current point from next point;
>-- take half of the difference;
>-- add that value to the value of the lowest of the two points;
>-- place that value at the end of the second sequence.
>
>-- copy next point in original sample to second sequence, and
>-- repeat above for the next point
>-- (the one that was previously the second point)
>
>-- then replace original with new,
>-- changing wavelen & ? so it will write & play correctly.
>
>procedure LowerPitch()
>integer diff
>sequence newWave
>newWave = {}
>
>   -- wave is the wave data, wave[1] is for mono
>   for n = 1 to wavelen do
>     newWave &= wave[1][n]
>
>     if n < wavelen then
>        diff = wave[1][n+1] - wave[1][n]
>        if diff != 0 then
>           newWave &= wave[1][n] + floor(diff / 2)
>        else  -- two successive points are the same value, so just copy 
>that
>value:
>           newWave &= wave[1][n]
>        end if
>     end if
>   end for
>
>   wave[1] = newWave
>   wavelen = length(wave[1])
>
>   changeStatus = 1
>   refresh()
>
>
>end procedure
>
>onClick[mnuWaveLowerFrequency]=routine_id("LowerPitch")
>
>--<end code>
>
>Dan Moyer

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu