Auralise annotations in Audacity

Using Nyquist scripts in Audacity.
Post and download new plug-ins.

Auralise annotations in Audacity

Permanent link to this post Posted by nuoritoveri » Tue Oct 30, 2012 2:32 pm

(I'm using Debian wheezy and installed Audacity from Debian package repository.)

Is there a way to auralise the label track in Audacity? What I want to achieve is each point label making sound when file is played and cursor goes over it. This will allow to check if they are placed right. I'm doing a beat annotation, so it is hard to check them the other way (you have to listen to bigger fragment of file to get the "beat sensation"; I get initial labels by listening to file and hitting Ctrl+M on beat-down).
Is there a way to do it in Audacity or using some Audacity plugin? Maybe there's a way to get exported annotation file back to audacity to generate "click track", then I will be able to mix it with file. Any solution including programming or using any other not-commercial tool is also acceptable.

I will be grateful for any ideas on this issue :)
nuoritoveri
 
Posts: 5
Joined: Tue Oct 30, 2012 2:14 pm

Re: Auralise annotations in Audacity

Permanent link to this post Posted by steve » Tue Oct 30, 2012 2:47 pm

It would be possible to create a Nyquist plug-in that can read data from an exported label track, but as far as I'm aware such a plug-in has not yet been written. Unfortunately plug-ins are not currently able to read label tracks directly.

There may be easier approaches.
Have you tried the Beat Per Minute labels plug-in?
If you can create a Click Track that matches the music, then you can create the labels using "Beat Per Minute labels" with the same tempo and the same starting point as the click track.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 34833
Joined: Sat Dec 01, 2007 11:43 am

Re: Auralise annotations in Audacity

Permanent link to this post Posted by nuoritoveri » Tue Oct 30, 2012 3:00 pm

Thanks for very fast reply :)

I will be working on files where beat period changes significantly so unfortunatelly I cannot just match bpm.
nuoritoveri
 
Posts: 5
Joined: Tue Oct 30, 2012 2:14 pm

Re: Auralise annotations in Audacity

Permanent link to this post Posted by steve » Tue Oct 30, 2012 3:19 pm

Two choices then I think.

If this is a one-off job then manual editing will be fastest.
If you will be doing this type of job regularly then writing a plug-in may be better.

Do you want help with how to best do this manually, or with writing a plug-in?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 34833
Joined: Sat Dec 01, 2007 11:43 am

Re: Auralise annotations in Audacity

Permanent link to this post Posted by nuoritoveri » Tue Oct 30, 2012 4:23 pm

You mean creating the Nyquist plugin that will make a short tick on each label? That would be great :) Do you think it's hard to do it? I may try it.

(I'm not sure what do you mean by manual way, I can employ someone to knock everytime they see cursor moving over label, but I don't expect it to be very accurate ;) )
nuoritoveri
 
Posts: 5
Joined: Tue Oct 30, 2012 2:14 pm

Re: Auralise annotations in Audacity

Permanent link to this post Posted by steve » Tue Oct 30, 2012 4:56 pm

Yes, definitely possible, though with the limitation that it cannot "read" labels directly, so you would need to either:
  • Export the label track, open it in a text editor, then copy and paste the label data (text) into a text window in the plug-in (much easier to code).
  • Export the label track and make the plug-in read the exported track (harder to code).

I would recommend going for the easier option. The harder option could be added later if required.

Have you done any programming previously? (not required)

I'd suggest that you start by having a read through this document (don't worry if you don't understand it all straight away): http://wiki.audacityteam.org/wiki/Nyqui ... _Reference
and for some hands-on experience try out some of the simple examples (don't bother with the "SAL" examples for now) here: http://wiki.audacityteam.org/wiki/Categ ... ist_Basics

Also, read through this (particularly the final section) so that you know what we are dealing with: http://manual.audacityteam.org/o/man/label_tracks.html

I'll have a think about how best to approach the task.
Feel free to ask questions.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 34833
Joined: Sat Dec 01, 2007 11:43 am

Re: Auralise annotations in Audacity

Permanent link to this post Posted by nuoritoveri » Tue Oct 30, 2012 6:12 pm

I think I will start from reading time labels from some list hard-coded in program.
I'm trying to understand clicktrack.ny plugin from Audacity distribution. (I think it's a good base it is a Generate type of plugin and has alread "make tick" code in it.)
I don't understand how do you "move in time" there.

For example I understand
Code: Select all
(osc pitch)

makes a sound of defined pitch. But how do you define for how long it lasts and at which time instant it happends?
nuoritoveri
 
Posts: 5
Joined: Tue Oct 30, 2012 2:14 pm

Re: Auralise annotations in Audacity

Permanent link to this post Posted by steve » Tue Oct 30, 2012 7:05 pm

nuoritoveri wrote:I think I will start from reading time labels from some list hard-coded in program.

Have a look at the list.
As long as you are not using label text, the list should look something like this:
Code: Select all
2.052789   2.052789   
4.105578   4.105578   
6.033197   6.033197   

Because you are creating "point" labels with Ctrl+M, the start and end time of each label is the same.
This will be useful to us as it means that all that we need to extract from the list is every other value.


nuoritoveri wrote:For example I understand
Code: Select all
(osc pitch)

Terrific.
There is also a convenient function hz-to-step
Because osc uses MIDI step values for the frequency, it is often convenient to use the hz-to-step function.
Some examples to try in the Nyquist Prompt effect
Code: Select all
; generate a 440 Hz tone
(osc (hz-to-step 440))

Code: Select all
; generate a 1000 Hz tone
(osc (hz-to-step 1000))

Code: Select all
; generate a 440 Hz tone that is twice as long as the selection
; Note that the "length" parameter is relative to the selection length
(osc (hz-to-step 440) 2)

Code: Select all
; generate a 1000 Hz tone that is half the length of the selection
(osc (hz-to-step 1000) 0.5)

Code: Select all
; generate a 440 Hz tone that exactly 3 seconds long
; note the use of ABS-ENV to create absolute time values
(abs-env
  (osc (hz-to-step 440) 3))


You can probably see how all of these brackets are working.
Nyquist is based on the programming language XLISP, which uses "fully parenthesized Polish prefix" notation.
What that means is that "functions" or "command" always come before (prefix) the "arguments" (values).
So for example, rather than writing:
3 + 2
The "+" is the "Add" function, so that goes first and the "arguments" follow:
+ 3 2

"Fully parenthesized" just means that every function goes inside its own set of brackets, so we end up with:
(+ 3 2)

So in our last example we have the function hz-to-step that converts 440 Hz into its "step" value (MIDI note number).

(hz-to-step 440) and 3 are then the "arguments" for the function osc to give us:
Code: Select all
(osc (hz-to-step 440) 3)


In turn, that becomes the argument for the function abs-env.

All of the sounds so far have been "full volume". We can make them bigger or smaller by scaling them. Scaling or amplifying a sound is the same as "multiplying" the sound by a value, so to make a sound have a peak level of half the track height, we can simply multiply it by 0.5
Code: Select all
(mult 0.5 (osc 72))


to be continued...
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 34833
Joined: Sat Dec 01, 2007 11:43 am

Re: Auralise annotations in Audacity

Permanent link to this post Posted by steve » Tue Oct 30, 2012 7:39 pm

nuoritoveri wrote:I don't understand how do you "move in time" there.


So far we've got how to generate tones and how to amplify them.
What would be useful would be if we could "shape" them so that they are not just a constant volume.

To do this we need to "multiply" them by something that varies - a number does not vary, it is a "constant".

Nyquist provides a feature called "control signals".
A Control signal is much like a sound (a waveform) but to improve efficiency they use a low sample rate, typically 1/20th of the track sample rate.
When a control signal is multiplied by a sound, the higher sample rate of the two is used for the output.

To create control signals we can use "piece-wise approximations" http://www.cs.cmu.edu/~rbd/doc/nyquist/ ... l#index379

The version that we will use is pwlv http://www.cs.cmu.edu/~rbd/doc/nyquist/ ... l#index384

Let's say that we want to create an envelope that rises from 0.2 up to 0.8 at half way and back down to 0 again at the end.
Much like the Audacity Envelope tool we create a number of "control points" which are pairs of "time and level" values.
The correct order of values for pwlv is:
time1, level1, time2, level2, time3, level3....
The first time value is assumed to be zero so that value is not entered.
So our function for the "envelope" is:
Code: Select all
(pwlv 0.2 0.5 0.8 1 0)

If you run that command on its own it will produce a very short waveform because of the low sample rate being "squashed" when it gets back to the Audacity track, so let's try multiplying it by a sound:
Code: Select all
(mult (osc 72)
  (pwlv 0.2 0.5 0.8 1 0))


Or if we want an exact time duration we can use something like:
Code: Select all
;; note that we use absolute time values for both the
;; sound and the control signal
(abs-env
  (mult (pwlv 0.2 1.5 0.8 3 0)
    (osc (hz-to-step 440) 3)))



So finally we get round to something useful - a little "beep" for our plug-in.
Code: Select all
(setq dur 0.1)
(setq hz 1000)

(abs-env
  (mult (pwlv 0 (* dur 0.1) 0.8 (* dur 0.9) 0.8 dur 0)
   (osc (hz-to-step hz) dur)))

I have used a "variable" called "dur" to hold the required duration - in this case 0.1 seconds,
and the variable "hz" to hold the frequency - in this case 1000 Hz.

To make the code easier to use in our bigger plug-in, I'll wrap the whole thing in a "function". http://www.audacity-forum.de/download/e ... ef-124.htm
We will create our own custom function called "beep" and it will take 2 "arguments" (parameter values) which will be the frequency and the duration.
Code: Select all
;;; make a beep
(defun beep (hz dur)
  (abs-env
    (mult (pwlv 0 (* dur 0.1) 0.8 (* dur 0.9) 0.8 dur 0)
     (osc (hz-to-step hz) dur))))

On its own this function does nothing. To make it do something we have to call the function (use it):

Code: Select all
;;; make a beep
(defun beep (hz dur)
  (abs-env
    (mult (pwlv 0 (* dur 0.1) 0.8 (* dur 0.9) 0.8 dur 0)
     (osc (hz-to-step hz) dur))))

; use the function 'beep' with a frequency of 440 Hz and a duration of 0.5 seconds
(beep 440 0.5)


to be continued....
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 34833
Joined: Sat Dec 01, 2007 11:43 am

Re: Auralise annotations in Audacity

Permanent link to this post Posted by steve » Tue Oct 30, 2012 7:50 pm

Topic moved to the Nyquist forum.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 34833
Joined: Sat Dec 01, 2007 11:43 am

Next

Return to Nyquist



Who is online

Users browsing this forum: No registered users and 2 guests