possible to make this plugin? ("auto draw wave")

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:

(setq new-length 100000) ; required length is samples
(force-srate (* (/ new-length len) *sound-srate*) s)

wow,…interesting, so you can use this plugin as a high-quality speed shifter?

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.

I think you may be looking for “Tracks > Resample”.

Thanks, audacity is more powerful than I thought :slight_smile: If you can just let me now if I can use your last plugin as a high quality speed shifter I’m done.

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.

(setq new-length 100000) ; required length is samples
(force-srate (* (/ new-length len) *sound-srate*) s)

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

Ok, thank you!

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 :slight_smile: 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.

Are we still talking about mono 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 : )

(setf a (extract 0 0.5 s))
(setf b (extract 0.5 1 s))
(extract 0 1 (seq b a))

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!

Possibly, it depends how you do it, but in any case, not much.

thanks, another “last” question if you don’t mind :slight_smile:

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”.

but it can look inside the selection, right? In fact this is how I would need it to work…I don’t care about the close points outside 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.

I admire your patience with a newbie like myself :slight_smile:

I would like the plugin to:

  • silence all audio before the first “crossing point” in the selection
  • silence all audio after the last “crossing point” in the selection

in other words, to trim the audio going from the first point to the second.