[audacity4blind] Re: Help with basic plugin development

  • From: Steve the Fiddle <stevethefiddle@xxxxxxxxx>
  • To: audacity4blind@xxxxxxxxxxxxx
  • Date: Sun, 6 Aug 2017 22:06:50 +0100

LISP has "lists" and "arrays". In Nyquist, arrays are limited to one
dimension, which are sometimes referred to as "vectors", but "lists"
and "arrays" are distinctly different data structures. Nyquist has
"list functions" that operate on lists, and array functions that
operate on arrays, but lists should not be confused with arrays
because they are different things, with different syntax, and
different functions for handling them.

The "PWL" family of functions operate with a list of parameters. For
more information, see this section of the Nyquist manual about
"piecewise approximations":
http://www.cs.cmu.edu/~rbd/doc/nyquist/part8.html#index405

Steve

On 6 August 2017 at 16:41, Marlon Brandão de Sousa
<splyt.lists@xxxxxxxxx> wrote:

Thanks.


I am still getting used to the audacity interface on Mac OS.


There is a button called manage near the preview button. I had never had the
curiosity to activate it and it turns out that the presets can be saved from
there. Thanks, productivity enhancing very quickly after that type.


Moving on with the plugin idea, please clarify me something:


What the pwl-list function does?

1- Loops through a uni dimensional list (what we know as a vector in C++
terminology) composed of a t and a l then a t and a l and so on .... and
applies several envelopes in series.
2- Loops through a list composed itself of a series of pairs if lisp offers
such constructions or composed of sublists containing a t and a l each (so
creating a bi dimensional array) and applies the envelopes in series.
3- Takes only one uni dimensional list with two items the first being a t
and the second a l and applies only one envelope.

This is what is confusing me, because by looking at the text envelope code I
could not determinate safely with a loop was being performed or not outside
of the pwl-list call.

By taking a look at the plugin code (remember that lisp has a extremely hard
syntax for me and that after the eleventh nested open parenthesis I hardly
can keep track of what is going on in the overall scene) I would think that
the pairs are put in two lists, then each list is individually sorted (and
this is the only reason they have been separated) and after they would be
interlaced on a uni dimensional final list of ordered t / l. This list would
then be sent to the pwl-list function which would apply the envelopes in
only one call. If this is right then the response to my question would be
the alternative 1. If this is right then I only need to find a good
reference on how to build lists from sal and I would be good. Since I am
sampling I can build the t l in the right order on the list. But without
knowing what kind of list pwl-list expects I won't be able to go forward.

Thanks,
Marlon


On 06/08/2017 05:04, Robert Hänggi wrote:

Hi Marlon

The Pwl function creates an envelope according to the T/L pairs given.

It works at the so called control-srate and this is one twentieth of
the sound-srate.

In order to have a greater precision, this envelope is being upsampled
to the actual rate of the track.

Imagine audio that is 209 samples long. This isn't divisible by 20.
Thus, the "Final amplification" will be either at 200 samples or 220.
In the first case, the envelope will tapper off at the end to zero
(which is implied for sample 220).
In the latter case, the final amplification won't ever be reached.

In other words, it is just a trick to ensure that the final sample is
exactly the value the user wanted it to be.


By the way, did you know that you can save presets for the text envelope
effect?

Robert

On 06/08/2017, Marlon Brandão de Sousa <splyt.lists@xxxxxxxxx> wrote:

Thanks!


I am not used to languages where you can not declare a data to be of a
given type. I should have known that it would infer the information
based on the division factor and tried 10.0 to signalize that it had to
be a float operation.

Now to the second part:

The text envelope plugin used a interesting mechanism to level the track
volume:

                (control-srate-abs *sound-srate*
                    (mult s (pwl-list cplist)))))

I can't understand what is going on here even having taken a look at the
manual.

My understanding is that the pwl-list function will apply an envelope on
a selection and that the list would be a single dimensional one
containing a time a level a time a level and so on.
Is this true? Why its using that result as a multiplication factor of
the sound rate? I do understand the sound rate as the sound speed or
velocity. I can't understand why one needs to control the sound speed
when amplifying that.

Marlon

On 05/08/2017 21:36, Steve the Fiddle wrote:

I don't know SAL very well because I've always used LISP syntax for
Nyquist, however, in both SAL and LISP, if you divide an integer by a
float, you get a float. So rather than dividing by 10, try dividing by
10.0

Also, you can force an integer to become a floating point number using
the "float" function.
For example, if you run this code in the Nyquist Prompt and use the
Debug button:

set a = 5
set b = 3
print (a / b)
print (a / float(b))
return "Done"

the debug window will show:

1
1.66667


Steve

On 6 August 2017 at 01:06, Marlon Brandão de Sousa
<splyt.lists@xxxxxxxxx> wrote:

Folks,

I am still analyzing a problem I am having with audacity.


This is that need I have to gradually level down a track from its
current
volume to -10 or -20 db in a given time and keep the level at that
time.


I have been using the text envelope plugin and that works great, but I
have
to manually calculate the iterations and build the pairs of time and
volume
every time and this is not productive.


I thought that I can make a ramp plugin that makes exactly the same
thing.
This would be beneficial for other blind people specially coming from
editors such as Amadeus Pro which offers this feature.


I therefore started to code the plugin but I have some questions. I do
recognize that this might not be the place to ask, but if we have folks
experienced in writting plugins this might also be of interest for
others
here.


If this is not the right place to ask, then can you direct me towards
the
right list or forum or anything where I can ask for help?


Here the questions go:


As I am going to do basically the very same thing the text envelope
plugin
does but in an automated form, I started to inspect the plugin code.


But I can't find my way around lisp. Because of that I have chosen sal
to
use as the plugin development language.


However, I couldn't find a good language reference.


1- The plugin specify two gui fields: the time interval where the
amplify
should happen and the amount of db (positive or negative) that must be
applied.

2- The time value is of type float-text ** because I want one to be
able
to
specify that the amplify should happen in say 2.5 seconds. The value of
the
db field is of type int-text, because I do not want to allow one to
amplify
by say -5,2 db.

3- Inside the main function I divide the time interval by 10 and also
the
amount of amp to apply by 10. The idea is that on each tenth of the
period I
will apply cumulatively one tenth of the total amplification, so that
when
the period ends the track will be at the desired level.

4- But now the first difficulty comes: the amplify by widget is defined
as
type int-text so that the user can not enter a decimal value.


;control amp-factor "Amplify by" int-text "DB" 0 -40 40


but this is causing me problems in the sal code.


set ampSample = (amp-factor / 10)


because amp-factor is defined as int-text, the result of the division
by
10
put on

ampSample is also integer. This is not desired because if the user
enters
say -5 on the db field the value ending in ampSample is 0 when it
should
be
-0.5.


I have not found a single page on the internet specifying how to force
a
variable to be float.


As soon as I get this part ready I will ask you the second question
related
to lists.


Thanks,

Marlon


The audacity4blind web site is at
//www.freelists.org/webpage/audacity4blind

Subscribe and unsubscribe information, message archives,
Audacity keyboard commands, and more...

To unsubscribe from audacity4blind, send an email to
audacity4blind-request@xxxxxxxxxxxxx
with subject line
unsubscribe

The audacity4blind web site is at
//www.freelists.org/webpage/audacity4blind

Subscribe and unsubscribe information, message archives,
Audacity keyboard commands, and more...

To unsubscribe from audacity4blind, send an email to
audacity4blind-request@xxxxxxxxxxxxx
with subject line
unsubscribe


The audacity4blind web site is at
//www.freelists.org/webpage/audacity4blind

Subscribe and unsubscribe information, message archives,
Audacity keyboard commands, and more...

To unsubscribe from audacity4blind, send an email to
audacity4blind-request@xxxxxxxxxxxxx
with subject line
unsubscribe


The audacity4blind web site is at
//www.freelists.org/webpage/audacity4blind

Subscribe and unsubscribe information, message archives,
Audacity keyboard commands, and more...

To unsubscribe from audacity4blind, send an email to
audacity4blind-request@xxxxxxxxxxxxx
with subject line
unsubscribe



The audacity4blind web site is at
//www.freelists.org/webpage/audacity4blind

Subscribe and unsubscribe information, message archives,
Audacity keyboard commands, and more...

To unsubscribe from audacity4blind, send an email to
audacity4blind-request@xxxxxxxxxxxxx
with subject line
unsubscribe


The audacity4blind web site is at
//www.freelists.org/webpage/audacity4blind

Subscribe and unsubscribe information, message archives,
Audacity keyboard commands, and more...

To unsubscribe from audacity4blind, send an email to
audacity4blind-request@xxxxxxxxxxxxx
with subject line
unsubscribe

Other related posts: