Audacity chain and Nyquist

Hi,

I’d like to select range of opened audio with Nyquist and then process it with Audacity.
Is it possible? How to do that? For example I would need to change tone of selected (using specific criteria) region.
Please help.

Regards

Paul

Hi Paul
Your question confuses me a little bit. Let’s assume that you’ve loaded a file into Audacity. You now must select the whole region, which afterwards shall be “seen” by Nyquist. This selection is always stored in the variable s. Everything that is outside your selection boundaries can’t be seen or manipulated by Nyquist. As an example, we take an 2 min track. Select all and open the Nyquist prompt. If you now enter

(print (get-duration 1))

and press ok (or better debug) the program will return the length of your selection in seconds. Portions of the selected area (variable s) can be modified and returned to Audacity. If you want to work with a specific part of the sound use the commands “extract” and “extract-abs”. For example, to select the first minute and store it in a variable you can type:

(setf my-selection (multichan-expand #'extract-abs 0 60 s))

The multichan-expand command ensures that this also works with a stereo track. The sound you return to Audacity must be the last expression in your code. Another example to illustrate this:

 (force-srate 22050 my-selection)

shall be our last expression. It resamples our selection from above to 22050 hz and returns it to Audacity. But Audacity takes for granted that the samplerate is still 44100 (i. e. the sample rate of the track) and since we now have only half the samples, the returned sound will only be 30 seconds and the pitch will be an octave higher. This returned sound is all that remains from your original selection. if you want to preserve the other parts of your sound you must store them also in a variable:

(setf my-unmodified-snd (multichan-expand #'extract-abs 60 (get-duration 1) s))

You can use the functions “sim” and “at”/“at-abs” to arrange these parts in a new sound. Something like:

(sim my-selection (at-abs 60 my-unmodified-snd))

. Please precise your question if this wasn’t the information you were looking for.

Hi,
Thanks again, Robert. As usually your replies are useful and you inspired me to precise requirements.
I awared that my task requires tens tone changes for separated parts of track that is opened. So I have to reformulate the task:
I need Nyquist code example how to change tone (without change tempo - similar as menu Effects->Change tone) for selected part of original track.
Grateful your hints I defined some markers that are convenient to be identified with no complex analysis (thanks also for those help).
So let’s say I found number of markers pairs that limits ranges for tone changes.
Each pair (from-time and to-time in seconds) defines range I want to change tone up (if woman’s output voice needed) or down (if man’s output voice needed). To find markers location I use simple modification of Analysis->SoundFinder that use simplified representation of original track. I’d like to modify directly original track ranges.
What do you think?
Thanks in advance

Paul

Do you mean “Change Pitch” Audacity Manual

Nyquist does not have a good “Change Pitch” effect, only a low quality effect of that type, or it can change the pitch and tempo (like “Change Speed” Audacity Manual )


Do you intend to mark the man/woman parts by hand, or are you hoping that Nyquist can do that automatically? If automatically, how can Nyquist know which part should be man and which part woman?

Steve is absolutely right. A good pitch-shift effect that is accessible within Nyquist is something we are all looking forward to being implemented. The current one is very simple and works with delay lines and results in a undesired reverberation output. In addition the fx is a little complicated since it uses a ratio rather than pitch intervals to define the pitch change. Here’s the description:

LISP-syntax for this FUNCTION(184/351): 
(PITSHIFT SND SHIFT MIX)
Category: Effects, as found in :  Stk.Lsp

Description:
A pitch shifter implemented in STK. The input sound, a single-channel or multi-channel SOUND is pitch-shifted by shift, a FLONUM ratio. A value of 1.0 means no shift. The parameter mix sets the mixture of input and shifted sounds. A value of 0.0 means input only (dry) and a value of 1.0 means shifted sound only (wet).

Even if there existed a good fx, it would not be sure that it is suited for speech. The human voice is built with so called formants. These are like the overtones of a played note on a instrument. The fundamental frequency of a male is about 190 hz and the one of a female at about 250 - 300 hz. You could think that it is enough to shift the whole sound up by a quint (f0 would be 285 hz). Unfortunately, the result is not satisfying, you can try it with any pitch-shift effect in Audacity or with the function in Nyquist (ratio up to 1.5). The reason for this are those formants which do not change in the same manner, they can accentuate totally other frequencies - higher or lower - depending on the speakers gender.
To find a good algorithm for the pitch-shifting of speech is something like the golden egg in speech synthesis and began 70 years ago with the phase vocoder. The (modified) PSOLA algorithm is maybe state of the art at the moment.
But feel free to experiment, maybe it would be helpful to pitch-shift the sound within certain frequency bands. It all depends on how accurate and convincing your result has to be.