[audacity4blind] Re: Help with basic plugin development

  • From: Steve the Fiddle <stevethefiddle@xxxxxxxxx>
  • To: audacity4blind@xxxxxxxxxxxxx
  • Date: Sun, 6 Aug 2017 01:36:38 +0100

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

Other related posts: