How can change frequency of audio file

you should really try to refrain from saying “operate the frequency” from now on. obviously it causes a lot of misunderstandings. also when posting an extremely long video it would make sense to give us the exact time that deals with the parameter you want to show us.

i personally feel like you’re talking about resampling a signal, aka changing the speed of the index that reads from the buffer. this pitches the signal up or down relative to its origin and also changes its speed (bpm)

Hello,
Sorry for missed providing exact time. So, is it possible to operate frequency and pitch?
Means I can operate frequency by increment/decrement index value of buffer. Right?
Let me correct if I am wrong.
And how can operate pitch?

I think many people tried to help you and to extract what you actually want to do. There is nothing people can do if you don’t answer the questions.

No one seems to know (myself included) what YOU mean with operating frequency. Nobody else is using that term, hence nobody knows what you mean.

It might be futile, since the answers were given before, so I might repeat what others said before, apologies if I don’t reference each one’s input.

Pitch and frequency are connected values.
A higher pitch means a higher frequency.
The third important parameter is speed, how fast the samples are produced. If you produce the samples faster, the frequency AND the pitch will be higher. To achieve that people use a resampler, means to change the samplerate effectively changing the speed the individual samples are produced.

This changes the duration of the signal. In an instrument that can be acceptable depending on use case, in a realtime effect this is impossible, because your effect needs to produce exactly the same number of samples it consumed. Changing the duration while keeping the pitch or changing the pitch while keeping the duration is called elastic audio (there are a few names for different strategies to achieve this).

That’s the reason why everybody is stumped with your reiterated question, how you want to change the frequency and the pitch independently, when they are the same thing.

Can you follow and maybe clear that up?
Feel free to ask further questions (except the question you asked that no one can answer :wink: )

2 Likes

Okay,
Let me share some videos. So, you can understand my question in details.

Please, check the above link.
We need to develop the same thing as done in these videos.

i watched both videos and it still seems like both knobs do the same thing, which is resampling, changing the speed of the playhead. you play the audio file at a different speed which retunes it

Okay,
So, now how can i develop same things?. You can see that how i am loading file and play it as i posted above. I tried to operate frequency by increment/decrement of buffer index. So, is it a right way?

Pitch shifting usually involves FFTs, converting to the frequency domain, shifting the pitch, and converting back to the time domain. Resampling can be as simple as changing the read head index and using linear interpolation for in-between values, but for any kind of decent quality you’re going to want to do something more. High-quality resamplers may also involve moving to the frequency domain and back. Really, neither pitch shifting nor resampling are topics that are small enough to answer in a forum post. You need to do some research on those topics. There is plenty of information out there to read, both online and in books.

I have to say I feel embarrassed with you still using that « operate frequency » expression which, as it was explained to you, doesn’t convey any useful information. It’s weird to me, given the massive amount of time and energy other people put in this thread trying to help you that you can’t even consider using the right words. In any technical field, vocabulary is probably the most important thing to learn and think about. It’s what ensure everyone is talking about one specific thing. It’s easy to learn, and also very satisfying. A hammer, a nail.

Sorry to say,
But what you want man? Are you trying to stop conversation or what? Because i am trying to provide more information related my question. So, all can understand and show me direction.

In the videos both examples appear to do the same thing as far as I can tell. They both change the playback speed (which is what I assumed you meant by frequency), and they both change the pitch (as a consequence of changing the playback speed).

To be clear, playback speed, sample rate, pitch, and frequency (although not a commonly used term for it) can all mean the same thing.

That being said it is possible to change the playback speed independent of the pitch and vice versa.

It’s still not clear how the two controls you would refer to would differ other than one would be measured in Hz and the other maybe cents? so maybe one would be a linear control the other logarithmic? that’s probably the only difference in the videos you posted - unless I’m missing something.

Since the videos you posted are of a specific piece of hardware, the Percussa SSP, it is possibly useful to refer to the manual if you want to know what it’s Frequency and Pitch settings do:

The Pitch, TuneC (coarse tune) and TuneF (fine tune) settings seem to correspond to what’s seen in the videos.

I agree with what others have said, that in terms of how each parameter operates on the sound they essentially do the same thing. Freq/Tune are for setting the pitch (playback speed) of the sample. The Pitch parameter is 1v/octave MIDI input: for every volt increase of the input, the sample’s pitch will go up by one octave.

your audio is in some kind of buffer. maybe a vector or an array. you’d usually increment its read index by 1 for each sample to play the sound. try incrementing by 2 and you’ll notice it’s an octave higher and twice as fast now. then ask yourself: “what happens if i increment by 1.5? and how do i use a float value to access the buffer?” this will lead you to the field of interpolation. the simplest one is just int(index). try that and hear the sound. it’s probably quite crushy, especially for value lower than 1 but you’ll already hear the pitching effect well. then learn about linear interpolation and if you feel adventurous maybe go on with splines. at that point your resampler should sound quite good for most cases

Hello Friends,
Thank you so much for your valuable reply, I am referring to all that you suggest me. Also, reading more about this. Because I thought that there should be some JUCE APIs to directly affect pitch and I can change sample rate/frequency by increment/decrement index value of buffer.

Hello Friends,
So, now i am very clear to distinguish frequency and pitch. So, let me make my question to specific. Actually, i want to change rate of sample. Currently, i am trying by changing index value of buffer. But is there any APIs to change rate of sample? or have to use classes suggested by @maxwellp777?

Yes, you will need to use interpolation to achieve that. Either roll your own or use the above suggested class.

So, i am trying to use Interpolation. But still not succeed to change sample rate. I have also check some examples. I am sharing one link which also used.

I also uploaded some lines of code which I modified to change sample rate.

Hello Guys,
Thank you so much for your support. I have stuck on this issue from a long time.
Now I am thinking to use a 3rd party library to solve this issue.
So, can I use the “Rubber Band” library here to add the functionality of pitch and frequency?

Hello Howard,

First, Let me clear my question. Sorry guys for the misunderstanding.
I need to use “Frequency” and “Pitch” Slider/Encoders as like below:

The pitch moves the speed of the sample in terms of semitones which are the musical intervals of a piano and freq. moves the pitch or speed of the sample based on hertz so as to be gradually increased or decreased in hertz

This still sounds like they are two controls that do the same thing

Indeed.

@kishanpatel in case you are not aware of it, but 12 semitones on the piano are the same thing as doubling the frequency in Hz.

For everything in between the mathematical ratio is a bit more odd, but you can always calculate “x semitones are the same as a frequency factor of y”. So yes. You likely want two controls with different value scales setting the very same thing under the hood. You have to controls expressing the same thing with different numerical values. I really hope you are aware of that. May I ask you from which background you are coming?

You could even build it in a way that moving one slider will simultaneously move the other one to the position where you would have achieved the same sound with the other option.