Plugin to find sample value in unsigned integer

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

If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like

Re: Plugin to find sample value in unsigned integer

Permanent link to this post Posted by abivenera » Wed Aug 31, 2016 9:49 am

Here is my Nyquist debug output when I copied and pasted your code(as below) in the Nyquist prompt -

(setf output "") ;initialize output string
(setf *float-format* "%.5f") ;output to 5 decimal places

;; Loop 20 times and return output string to debug window
(dotimes (i 20 (format t output))
(setf output
(abs-env
(format nil "~a~%~a ~a"
output
(1+ i)
(sref *track* (/ i *sound-srate*))))))


OUTPUT:(Nyquist prompt debug output)-

error: unbound variable - *TRACK*
if continued: try evaluating symbol again
Function: #<FSubr-PROGV: #a7f12b0>
Arguments:
(QUOTE (*WARP* *LOUD* *TRANSPOSE* *SUSTAIN* *START* *STOP* *CONTROL-SRATE* *SOUND-SRATE*))
(LIST (QUOTE (0.00000 1.00000 NIL)) 0.00000 0.00000 1.00000 MIN-START-TIME MAX-STOP-TIME *DEFAULT-CONTROL-SRATE* *DEFAULT-SOUND-SRATE*)
(FORMAT NIL "~a~%~a ~a" OUTPUT (1+ I) (SREF *TRACK* (/ I *SOUND-SRATE*)))
Function: #<FSubr-SETF: #a7f4420>
Arguments:
OUTPUT
(ABS-ENV (FORMAT NIL "~a~%~a ~a" OUTPUT (1+ I) (SREF *TRACK* (/ I *SOUND-SRATE*))))
Function: #<FSubr-DOTIMES: #a7f2d50>
Arguments:
(I 20 (FORMAT T OUTPUT))
(SETF OUTPUT (ABS-ENV (FORMAT NIL "~a~%~a ~a" OUTPUT (1+ I) (SREF *TRACK* (/ I *SOUND-SRATE*)))))
1>




What is the problem according to you now ?? Is there something wrong with my Audacity??
abivenera
 
Posts: 11
Joined: Mon Aug 29, 2016 6:09 am
Operating System: Windows 8 or 8.1

Re: Plugin to find sample value in unsigned integer

Permanent link to this post Posted by steve » Wed Aug 31, 2016 11:11 am

abivenera wrote:error: unbound variable - *TRACK*

Either you are using an obsolete version of Audacity, or you have "Use legacy (version 3) syntax" selected.

If you are using Audacity 2.1.2, ensure that "Use legacy (version 3) syntax" is not enabled (not selected) in the Nyquist Prompt effect.
If you are using an old version of Audacity, get Audacity 2.1.2 from here: http://www.audacityteam.org/download/

To check the version Audacity number in Windows or Linux, look in "Help > About Audacity". On a Mac, look in the Audacity menu > About Audacity.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 43442
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux Debian

Re: Plugin to find sample value in unsigned integer

Permanent link to this post Posted by abivenera » Thu Sep 01, 2016 5:45 am

Thanks a lot you were absolutely right. The legacy version 3 was enabled for the nyquist prompt.Now the legacy version 3 is also enabled for the plugins.Please tell me how can I disable it so that I can make a plugin now ???
abivenera
 
Posts: 11
Joined: Mon Aug 29, 2016 6:09 am
Operating System: Windows 8 or 8.1

Re: Plugin to find sample value in unsigned integer

Permanent link to this post Posted by abivenera » Thu Sep 01, 2016 7:18 am

I got to know how to exclude legacy version 3 syntax in our plugin.We need to have " ;version 4 " in our code to disable legacy version 3 syntax.
abivenera
 
Posts: 11
Joined: Mon Aug 29, 2016 6:09 am
Operating System: Windows 8 or 8.1

Re: Plugin to find sample value in unsigned integer

Permanent link to this post Posted by steve » Thu Sep 01, 2016 7:34 am

abivenera wrote:We need to have " ;version 4 " in our code to disable legacy version 3 syntax.

Yes, You just need to include the ";version 4" header command and that will tell Audacity to interpret the code as version 4 code. See: http://wiki.audacityteam.org/wiki/Nyqui ... ce#version
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 43442
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux Debian

Re: Plugin to find sample value in unsigned integer

Permanent link to this post Posted by abivenera » Thu Sep 01, 2016 11:49 am

Hii Steve I am undergoing a new problem now. My plugin that I developed to display the sample value of selected region using below code -

Code: Select all
(abs-env (print (sref *track* (/ samplenumber *sound-srate*))))



The problem is that when I am running this plugin for some other audio file its showing the below thing in DEBUG -

Code: Select all
error: bad argument type - #(#<Sound: #5a2d328> #<Sound: #5a2d568>)
Function: #<Subr-SND-SREF: #ab5e068>
Arguments:
  #(#<Sound: #5a2d328> #<Sound: #5a2d568>)
  0.839583
Function: #<Closure-SREF: #ab828e8>
Arguments:
  #(#<Sound: #5a2d328> #<Sound: #5a2d568>)
  0.839583
Function: #<FSubr-PROGV: #ab60068>
Arguments:
  (QUOTE (*WARP* *LOUD* *TRANSPOSE* *SUSTAIN* *START* *STOP* *CONTROL-SRATE* *SOUND-SRATE*))
  (LIST (QUOTE (0 1 NIL)) 0 0 1 MIN-START-TIME MAX-STOP-TIME *DEFAULT-CONTROL-SRATE* *DEFAULT-SOUND-SRATE*)
  (PRINT (SREF *TRACK* (/ SAMPLENUMBER *SOUND-SRATE*)))
1>


What can be the reason for this ??? How can I correct it .
Last edited by steve on Thu Sep 01, 2016 12:54 pm, edited 1 time in total.
Reason: code tags added for readability
abivenera
 
Posts: 11
Joined: Mon Aug 29, 2016 6:09 am
Operating System: Windows 8 or 8.1

Re: Plugin to find sample value in unsigned integer

Permanent link to this post Posted by steve » Thu Sep 01, 2016 1:00 pm

abivenera wrote:What can be the reason for this ??? How can I correct it .

Your code is trying to find the value of a sample in a "sound", but your trying to apply it to a stereo track.
The data from a stereo track is not one "sound" but an array containing two sounds (one sound for each channel).

To access an element from an array, there's the command AREF file:///home/steve/Documents/Audacity/Manuals/xlisp/xlisp-ref/xlisp-ref-029.htm

So to access the sound in the left channel of a stereo sound *track*:
Code: Select all
(aref *track* 0)
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 43442
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux Debian

Re: Plugin to find sample value in unsigned integer

Permanent link to this post Posted by abivenera » Thu Sep 01, 2016 1:19 pm

Can you provide the code to print the value of sample value of a sample using *track* . I tried a lot but its not working.
abivenera
 
Posts: 11
Joined: Mon Aug 29, 2016 6:09 am
Operating System: Windows 8 or 8.1

Re: Plugin to find sample value in unsigned integer

Permanent link to this post Posted by steve » Thu Sep 01, 2016 2:02 pm

abivenera wrote:Can you provide the code to print the value of sample value of a sample using *track* . I tried a lot but its not working.

I did that here: viewtopic.php?p=312349#p312349
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 43442
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux Debian

Re: Plugin to find sample value in unsigned integer

Permanent link to this post Posted by abivenera » Fri Sep 02, 2016 5:11 am

Actually Steve I got to know how to code when more than one channels are present .
In order to get sample value of Nth sample when more than one channel is present -

1. (abs-env (print (sref (aref *track* 0) (/ samplenumber *sound-srate*))))

The above code will work when more than one channel is present in the track

In order to get sample value of Nth sample when one channel is present -

2. (abs-env (print (sref *track* (/ samplenumber *sound-srate*)))

This code will work when one channel is present in our track

Correct me if I am wrong somewhere. Now I want to know a IF condition so that my code will execute the 1 code statement when more than one channel are present and will execute 2 code statement when one channel is present. This is because I want to write only one plugin that will be generic to all cases. How can I code that IF condition ????
abivenera
 
Posts: 11
Joined: Mon Aug 29, 2016 6:09 am
Operating System: Windows 8 or 8.1

PreviousNext

Return to Nyquist



Who is online

Users browsing this forum: No registered users and 5 guests