java - Linear interpolation - audio pitch shift -
I am trying to transfer pitch to a sample. I am using linear interpolation method.
If the deposit amount is a complete integer value, then the pitch is clearly transferred. If the amount being transferred to the pitch is logical, then the sound is very distorted. Implementation starts working.
This is my code, I tried to comment well.
Public Zero Generated AutoTrack () {Note currNote; Float [] output = new float [pattern. GetPlayTimeInSmps ()]; // #samples takes total time of pattern. Float [] currSample = sample.getData (); // PCM data of sample int currPeriod = 0; // sample int outputPtr = 0; // Use the next note length to use the output buffer array float pitch in the next digit; // float linInt = 0; // Linear Interpolator Float Phase PTR = 0; // floating point index sample intrate ptr = 0; // Integer Index Sample JavAud.checkRange (currSample); While ((currNote = pattern.nextNote ())! = Null / / each recurrence plays a note (currPeriod = currNote.getPeriodInSmps (); // the length of the current note in the samples pitch = currNote.getPitch (); // pitch For the current note (int i = 0; i & lt; currPeriod; i ++) // Run {pttr = (int) phasePtr; // floating point index for the length of the note linInt = phasePtr-ptr; // if We do not have to output at the end of sample copy data (ptr & lt; currSample.length * (1 / pitch) -1) {// linear interpolation pitch transfer output [outputPtr] = (currSample [ptr + 1] * linInt ) + (CurrSample [ptr] * (1-linInt)) // The alternate pitch is transferred from leaving a simple sample (there is less distortion) // output [outputPtr] = curls Edit [ptr];} Else // else silent {output [outputPtr] = 0;} OutputPtr ++; phasePtr = phasePtr + pitch ;} PhasePtr = 0;} JavAud.checkRange (Output); WavFileWriter Writer = New WavFileWriter (); Writer.writewave (new wavfile (1, javad.GLB_SMP_RATE, output), "outputtone.wav");}
It seems that you are trying to make a pitch shift by resampling. A common way to reprint better quality from linear interpolation is to use a windowed sync low-pass filter as your launch kernel. Here's the pseudo code for a slow (slow) method of window sync resembling:
Comments
Post a Comment