Not a problem.
If you get the audio as close as possible to the required length with perfect complete samples (as described in my previous post) then you can stretch the entire track a little to fit the required length using this code:
oh and one other thing: do you now a way to “update” the audio when you change the sample rate in a project.
If I change it I have to export all audio and import it again before I see some change in the sample amount per wave cycle.
It’s not particularly “high quality”. Audacity’s “Change Speed” effect is higher quality, particularly for higher frequency signals, but this one allows very precise (sample accurate) length stretching and the quality is quite good enough for low frequency signals.
Not much to say about it really. Use it in the Nyquist Prompt as before. In the first line replace “100000” with the actual duration that you want (in samples).
If you’ve not noticed, the Selection Toolbar at the bottom can be set to show the number of samples: Audacity Manual
this may sound like a strange request, but does someone know how to make a plugin that copies the first half of a selection, deletes it and pastes it back right after the selection.
example: selection = 10 samples in length, the sample order 1 2 3 4 5 6 7 8 9 10 becomes 6 7 8 9 10 1 2 3 4 5 after using the plugin. (1 to 5 was copied, deleted and pasted at the end of the selection)…might sound stupid but very practical to me.
I’m probably making too many demands but preferably the plugin shouldn’t join the 2 resulting parts. This way I can see where the “cut” is made (between 10 and 1 in my example).
That part can’t be done at present.
Audacity send one lump of audio (the “selection”) to Nyquist, and Nyquist can return one lump of audio back to Audacity. Nyquist has no concept of audio clips or anything else about Audacity tracks.
Yes, mono tracks! I will always use the entire track as a selection. Not sure if it is easy to program
the plugin so that it auto-detects the length of a track. If so I could select the full project and have
the plugin processing all tracks ( with different lengths) at once : )
works like a charm thank you! very last question! if you resample a track to a higher resolution, and you resample back to the original, is there any loss of quality?
Thanks for all your help!
Is there a way in audacity to speed-shift multiple tracks at once to a same frequency? The change-percentage is different for all of them because they all have their own frequency…(chromatic samples)
If you want the code to detect the frequency and then calculate the amount of speed-shift to tune it to a specified frequency, that is difficult. The difficult part is to accurately detect the frequency, unless you already know something about the selected audio. For example, if you know that there are exactly 100 cycles of the waveform, then it is relatively easy to calculate the frequency. If it is just an arbitrary waveform of unknown frequency, then accurately determining the frequency is difficult.
thank you for your reply, I can calculate the percentage for each track, just a lot of work to open the plugin window for each single track, but I finished it anyway.
The “find zero crossing point feature” is very practical…I almost don’t dare to ask (you already helped me out a lot) but, would it be a lot of work to make a plugin
that does the same for a custom value (other than zero)? for example move the selection to the closest 0.257 points…best, Nils
Nyquist effects only know about the audio that is passed to them, which is the “selected” audio. They have no idea about audio before or after the selection. The “find zero crossing” feature will search both forward and backward from the selection ends (both inside and outside of the selection) and look for the nearest zero crossing point, favouring positive going slopes. Nyquist can’t “look outside of the selection”.
Nyquist can find the first point in the selection where the waveform crosses any threshold that you specify, but it can’t change the selection start/end point. Nyquist just receives a lump of audio (from the selection), processes it, and returns it to Audacity. Nyquist has no concept of tracks or selections, it only knows about the audio that is passed to it. So you could do “something” based on the point at which a specified level is first crossed, but you’ve not said what you want to do.