Re: bug? my fault? makearray won't work.

This section is now closed.
Forum rules
Audacity 1.2.x is now obsolete. Please use the current Audacity 2.1.x version.

The final version of Audacity for Windows 98/ME is the legacy 2.0.0 version.
jan.kolar
Posts: 273
Joined: Sat May 24, 2008 7:01 pm
Operating System: Please select

Re: bug? my fault? makearray won't work.

Post by jan.kolar » Tue May 27, 2008 10:48 pm

{{edited by JK, again edited June 20, 2008}}

The content of posts of Volta-X, in particullary of the one where the problems are formulated was deleted/modified by the author itself.

The problems were:
1. How to create a Nyquist effect with mono input and stereo ouput?
2. Why makearray does not work (for me)?

About the solutions:

Currently Audacity allows to apply Nyquist effects to a mono track and to a stereo track.
The input is assigned to a variable 's' and it is represented as a 'sound' or an array of two 'sounds'.
The output of the effect is the value of last successfully evaluated expression in the script.
If the output is the sound of the same type as input (mono/stereo), it replaces the input on the track in Audacity.
[What happens if the size is different for the old and new sound?]
(If the output is a text or number, it is displayed in a message box. If the output is an appropriately formatted list, a labels are created on a label track.) If the output is not of correct type, Audacity displays 'Nyquist did not return audio' error message.

The one-or-two-channel limitation is not fundamental and could be changed in future version of Audacity if there is sufficient demand for this new feature and if there is programmer to implement it. Important aspect would the design of the interface. (It should be compatible to the current one which includes the 's' variable and the current behaviour when multiple tracks are selected.)

1. For the first problem, the following steps lead to the solution: A stereo track is created, where input is placed in the first channel and any (e.g., the same or zero) sound is placed in the second channel. The script ignores the second channel and outputs a stereo sound. When writing the script, one is likely to encounter problem caused by multiple evaluating of 's', for example the output might have half the size of the input. The solution is to use '(cue s)' instead of 's'.

2. There is no problem with make-array or vector functions. It turned out that in the case two rules had to be followed: (1) If the input to Nyquist script is mono, Audacity expects mono output, if the input is stereo, Audacity expects stereo output. (2) Audacity does not accept NIL as a sound; likewise it does not accept (vector NIL NIL) as a stereo sound. While this is perhaps different to behaviour of Nyquist when used outside of Audacity, it is consistent and moreover, it is Nyquist itself who sais that (soundp NIL) si not true, which I can see by putting (cond ((soundp NIL) "yes") (T "no")) into Nyquist prompt. Do more recent versions of stand-alone Nyquist behave otherwise?

----------------------------------------------------


As regards your question:
I think you want one track input and two track output for a Nyquist effect.
Then I'd guess you would need to create an addional track with silence (or possibly empty?),
connect them to a single stereo track and a select two of tracks before calling Nyquist.
Than Nyquist can return a stereo track, too.
There might be on other way but I do not know about that.



Stereo tracks are arrays in Nyquist.
Select a part of a stereo track. Then

Code: Select all

(setf ss (make-array 2)) 
(setf (aref ss 0) (aref s 1))
(setf (aref ss 1) (aref s 0))
ss
swaps the channels.

The following does the same, but I do not know - is it less expensive?

Code: Select all

(setf x (aref s 0))
(setf (aref s 0) (aref s 1))
(setf (aref s 1)  x)
s
{{updated May 29 -- I did not notice the sound is chunck-splitted to the two channels.
To duplicate really, one can introduce 'cue' function -- see one of the later posts here.
Sorry for not testing my script carefully.}}
The following does {{not}} what you want - it duplicates {{not}} the sound of left channel.
Modify it to your needs, e.g. Replace "x" on the last line by "(SOMEEFECT x)".

Code: Select all

(setf x (aref s 0))
(setf (aref s 0) x)
(setf (aref s 1) x)
s
{{ For a working corrected script see

Code: Select all

(setf ss (aref s 0))
(vector (cue ss) (cue ss))
[/size]
or

Code: Select all

    ; our input is in the left channel
(setf inputchannel (aref s 0))
    ; we ignore the right channel.
   ; the folowing line is useless a can be deleted !!
(setf ignoredchannel (aref s 1))

(setf sL (cue inputchannel))
(setf sR (cue inputchannel))
(display "what is (vector sL sR)    " (vector sL sR))
(vector sL sR)
[/size]
in a later post of myself. See also the two scirpts just bellow that one.}}[/color]


This was certainly not a question for developers. {I mean it is for users as I am.
But I uderstand(?) your feeling it could be a nyquist problem.}
Last edited by jan.kolar on Fri Jun 20, 2008 8:39 pm, edited 3 times in total.

jan.kolar
Posts: 273
Joined: Sat May 24, 2008 7:01 pm
Operating System: Please select

Re: bug? my fault? makearray won't work.

Post by jan.kolar » Wed May 28, 2008 8:57 am

Sorry, I must quit before finished.

Super fast reply:

Probably the main point is: vector is probably all right,
but we can not return stereo data when Audacity expects mono data.

cf. first frame in
http://www.audacity-forum.de/download/e ... htm#stereo
where conditional can be rephrased:
if input is stereo, return stereo, if not return mono.

Your expression converts mono to stereo so can not be expected to work.

-------------------


Quick answer:
Probably I did say something wrong?? Sorry.
I am lost too, Are you a developper?
Our should I not answer if I am not developper and do not know what you mean by guys
Perhaps I wanted to say - it is perhaps just a user level question.
(aw, is there anywhere has chance to ask developers directly or i gotta come down here...)
TO GUYS AND ESPECIALLY DEVELOPERS


---------------------------


You can make my code a nyquist script? Can not you? I will test later.
But I thought it is enough to put a ;version-control-whateverelse header to make it a plugin/efect/analyze.

Code: Select all

(setf (aref ss 0) (aref s 1))
means
take "(aref s 1)" which is the mono sound of the right channel of s (s is the stereo input to nyquist script)
and put it as the left channel of ss.

Code: Select all

(setf (aref ss 0) (ANEFFECT (aref s 1) PARAM)
would mean
take "(aref s 1)" which is the mono sound of the right channel of s (s is the input to nyquist script)
process it by "ANEFFECT" (with some more PARAMeters)
and put it as the left channel of ss.



Probably the main point is: vector is probably all right,
but we can not return stereo data when Audacity expects mono data.


Later I return to all that (and edit the post a bit?)
I am sorry I have no the quit this computer quickly, so you put some heap of links below,
mainly for my own reference - sorry.


Audacity and Nyquist - Official Audacity Nyquist plug-in documentation
http://www.audacity-forum.de/download/e ... yquist.htm


Audacity and Nyquist 2007 -- Updated plug-in information, 2007
http://www.audacity-forum.de/download/e ... ist-en.htm


in particular:

Stereo
http://www.audacity-forum.de/download/e ... htm#stereo
Return values
http://www.audacity-forum.de/download/e ... htm#return







Nyquist Examples and Tutorials
http://www.audacity-forum.de/download/e ... amples.htm



steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: bug? my fault? makearray won't work.

Post by steve » Wed May 28, 2008 5:38 pm

Nice post jan.

The fancy text is done using BBC code

I think jan is Czech. I believe the Czech language is similar to Slovak, and to a lesser degree to Polish.

Volta is not an Audacity developer, and his original question does not specifically require the attention of Audacity developers.

"make-array" works within the Audacity implimentation of Nyquist, but as jan says, you cannot return stereo data to a mono track.

Re. the small text: Most browsers have the facility to make text larger, usually through the "View" menu. But in case you have a browser that does not support this, here it is at normal size:

Audacity and Nyquist - Official Audacity Nyquist plug-in documentation
http://www.audacity-forum.de/download/e ... yquist.htm

Audacity and Nyquist 2007 -- Updated plug-in information, 2007
http://www.audacity-forum.de/download/e ... ist-en.htm

in particular:

Stereo
http://www.audacity-forum.de/download/e ... htm#stereo
Return values
http://www.audacity-forum.de/download/e ... htm#return

Nyquist Examples and Tutorials
http://www.audacity-forum.de/download/e ... amples.htm
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

jan.kolar
Posts: 273
Joined: Sat May 24, 2008 7:01 pm
Operating System: Please select

Re: bug? my fault? makearray won't work.

Post by jan.kolar » Wed May 28, 2008 10:44 pm

Your inital code was
(setf s (make-array 2))
(vector s s)
I think it does this:

Nyqist is supplied sound in variable s.

First line
1. creates an array (exactly, an array of two NILs),
2. Forgets the content of s, that is it forgets the sound
3. sets s to be the array from 1.
4. Probably retuns the name of s (symbol of s), which is ingored, probably.
Second line
1. creates a vector of two s
2. returns the vector.
So audacity gets vector of two s,
which is vector of two arrays, each of them containg two nothing-items.

We can see what is going on with display function:

Code: Select all

(display "what is s when starting:" s)
(setf s (make-array 2)) 
(display "what is s after (setf s...):" s)
(display "what is (vector s s):" (vector s s))
(vector s s)
If I put it into Nyquist prompt, press Debug and I get

Code: Select all

what is s when starting: : S = #<Sound: #15023a0>  
what is s after (setf s...): : S = #(NIL NIL)  
what is (vector s s): : (VECTOR S S) = #(#(NIL NIL) #(NIL NIL))  
[ gc: total 18640, 3673 free; samples 1KB, 0KB free ]
So indeed Audacity gets indeed #(#(NIL NIL) #(NIL NIL))
and therefore it complains "Nyquist did not return any audio".
The line [gc: total ......] contains only information of memory management
(LISP uses garbage collection strategy)

Lets try only the second line (plus "display". Done as before: Nyq. prompt, Debug)
(display "what is (vector s s) " (vector s s))
(vector s s)
Now, Audacity complains "Nyquist returned too many audio channels".
That means, Audacity got stereo, but expected mono because I select a mono track.
Debug output is

Code: Select all

what is (vector s s)     : (VECTOR S S) = #(#<Sound: #1502628> #<Sound: #1502628>)  
[ gc: total 18640, 3673 free; samples 1KB, 0KB free ]
Good, (vector s s) is vector of two sounds, that is a stereo sound.

Lets try to select a stereo track for the same Nyquist code.
The message from Audacity is "Nyquist did not return any audio"
and the debug output is

Code: Select all

what is (vector s s)     : (VECTOR S S) = #(#(#<Sound: #1502628> #<Sound: #15026e8>) #(#<Sound: #1502628> #<Sound: #15026e8>))  
[ gc: total 18640, 3671 free; samples 1KB, 0KB free ]
That is an array of two arrays of sounds,
that is an array of two stereo sounds.


Lets try use only one track (still, I select stereo input, and I will alwasy do from now on):

Code: Select all

    ; our input is in the left channel
(setf inputchannel (aref s 0))
    ; we ignore the right channel.
    ; the folowing line is useless a can be deleted !!
(setf ignoredchannel (aref s 1))

(setf ss inputchannel)
(display "what is (vector ss ss)    " (vector ss ss))
(vector ss ss)

Code: Select all

what is (vector ss ss)     : (VECTOR SS SS) = #(#<Sound: #15023a0> #<Sound: #15023a0>)  
[ gc: total 18640, 3673 free; samples 1KB, 0KB free ]
Now, no complains from Audacity. The debug output is what I expect.
But, allas, the new tracks are half time long. And obviously
one chanel got even chunks of length 1020 (not 1024, but 1020, probably some 4bytes header)
and the other channel the odd ones. (both Audacity 1.2.6 and 1.3.5.)
Is that a b/u/g or a feature?
Volta-X, is this one of your experiences? Then I understand you putting bug
into the subject and calling develeppers.
Perhaps we are told in documentation to duplicate the sound somehow
before returning it twice to audacity?

The same happens for the equivalent minimal codes

Code: Select all

(setf ss (aref s 0))
(vector ss ss)
and

Code: Select all

(vector (aref s 0) (aref s 0))
Now trying to look at reference manual, though unintentionaly sliding to examples>examples from manual , there are some
examples applaying strange 'cue' function to sounds. I know cue from browsing internal
Nyquist scripts and Nyquist plugins, that might be important.
And I see, it appears when several copies of sound are used. Lets try:

Code: Select all

(setf ss (aref s 0))
(vector (cue ss) (cue ss))
(Applied to a stereo track. Is intended, it copies content of L channel to R channel).
The long fancy form:

Code: Select all

    ; our input is in the left channel
(setf inputchannel (aref s 0))
    ; we ignore the right channel.
   ; the folowing line is useless a can be deleted !!
(setf ignoredchannel (aref s 1))

(setf sL (cue inputchannel))
(setf sR (cue inputchannel))
(display "what is (vector sL sR)    " (vector sL sR))
(vector sL sR)
Now I wanted to let you find yout yourself in the documentation what is going on.
Unfortunately I hit on something related unintentionaly, so prehaps I must tell you:
http://www.audacity-forum.de/download/e ... t3.html#23
Please tell me, is 'cue' the correct solution?



Finaly, let us make it some-kind-of-effect.
(recall: applies to left chanel of a STEREO track, right channel is discarded,
output is in both channels)

Code: Select all

    
; our input is in the left channel
(setf inputchannel (aref s 0))
    ; we ignore the right channel.
   ; the folowing line is useless a can be deleted !!
(setf ignoredchannel (aref s 1))

(setf sL (mult (hzosc 0.45) (cue inputchannel)))
(setf sR (mult (hzosc 0.5) (cue inputchannel)))
(display "what is (vector sL sR)    " (vector sL sR))
(vector sL sR)
Now that was used as input Nyquist prompt (I mean that one of Audacity, listed in the Effects menu).
Can you try to do it as a plugin yourself? Does it work for you?
I think that running something in Nyquist prompt is the same as to put it into plugin file
(with the diference of oblicatory and facultatiov headre files. For example I had no "controls" to set the values of variables etc.)

(Might be, cue can be removed from the above example again? It seems, at least,
to have an influence on what I report as a bug in the following post)
Last edited by jan.kolar on Thu May 29, 2008 12:00 am, edited 1 time in total.

jan.kolar
Posts: 273
Joined: Sat May 24, 2008 7:01 pm
Operating System: Please select

A bug? Audacity window hides sometimes after Nyquist

Post by jan.kolar » Wed May 28, 2008 11:21 pm

It happend repeatedly. (I thought it crashed !!)

The following would be details for reproducing the bug,
but it is dificult to catch what is important.
However if play with like that, it happens again.

Start Audacity 1.3.5.(unicode, Czech) (windows XP)
Generate Tone, 10s, 140Hz (otherwise default 440 Hz, amp=1)
New track
Generate Tone, the same, freq 1000Hz
Vytvorit Stereo Stopu ( = Make/create stereo track)
Select the track
Efects > Nyquist Command Prompt
switch to IExplorer, (might work with notepad, too)
not important: Audacity Forum, Edit of my current post,
the view of my previous post, copy code,
switch back
not important: paste code
Debug
OK (on the debug window)
Now it probably hides.

If it does not hide completely, the window probably disappears at least
for several miliseconds :-) (On pentium 500Mhz notebook)

Added by Gale 04 June 08: I can't reproduce in 1.3.5, but Jan finds this is not a problem in a latest development build he tried.

Added by Jan: Unfortunately, the most important thing was missing: Which code (the one below) to copy to Nyquist. http://www.audacityteam.org/forum/viewt ... =20#p18496 (And it indeed appears to be fixed in recent builds.)

Code: Select all

(display "what is s when starting:" s)
(setf s (make-array 2)) 
(display "what is s after (setf s...):" s)
(display "what is (vector s s):" (vector s s))
(vector s s)
[/size][/color]
Last edited by jan.kolar on Fri Jun 20, 2008 9:13 pm, edited 6 times in total.

jan.kolar
Posts: 273
Joined: Sat May 24, 2008 7:01 pm
Operating System: Please select

Re: bug? my fault? makearray won't work.

Post by jan.kolar » Thu May 29, 2008 12:11 pm

OK, lets do it the other way around.
You write the "efect" part of your efect, give me the script, and I modify
it as regards the "mono to stereo" problem you can not solve.

Lets by an arrow "-------->" donote some proccesing of sound.

You want to write a Nyquist plugin that does the following:

(*) monosound -----> stereosound.

Stereo sound are just two channels of mono sound (properly synced).

Thus (*) is the same as

(**) monosound -----> monosound for LEFT channel, monosound for RIGHT channel.

This can be divided into two tasks: (sometimes naturally, sometimes artifficially, but id does always.)


monosound -----> monosound for LEFT channel.

monosound -----> monosound for RIGHT channel.

So please, write two effects doing the two above lines,
and you finish the script for you (I will add just a few lines with cue and make-array or vector).
Do not forget to test the scripts. (If in doubt, I will ask you for sample input and output for it.)

If this would take to much time for you, just send me any two distict mono-to-mono effects and I will show you as per example. ('Distinct' means simply that you can observe the difference between the two, for this purpose.)

jan.kolar
Posts: 273
Joined: Sat May 24, 2008 7:01 pm
Operating System: Please select

Re: bug? my fault? makearray won't work.

Post by jan.kolar » Thu May 29, 2008 12:40 pm

When you are writing a mesage, there is a line of buttons just above:
B i u Quite Code List List= [*} Img URL Normal Font colour.

I understand so far half of them. One of them is code.
Write (copy) some code like
first line
second line
third line
Select the code by mouse and press Code button. the result is like that:

Code: Select all

first line
second line
third line
There is also possibility to make attachments (somewhere below the editiong window.)
I had a 'problem' with them -- so do not ask me about attachments if they fail for you. However I thing the problem
was with my eyes, the symbol of attachments is somewhat to small.

If you want to do something with make-array (You do not really necessarily that, I think.)
you do not need speek seven languages or see the small attachment symbol with your eyes,
but you need skills like that with code box and much more than this.

jan.kolar
Posts: 273
Joined: Sat May 24, 2008 7:01 pm
Operating System: Please select

Re: bug? my fault? makearray won't work.

Post by jan.kolar » Thu May 29, 2008 12:47 pm

Volta-X wrote:i'd like to create 2-arrays-dual-mono-track (i.e. fake stereo track). and this is important, i like to create it out of ONE-ARRAY-MONO-TRACK BY THE SCRIPT.

(setf s (make-array 2))
s

or

(setf s (make-array 2))
(vector s s)

{{JK: there were missing ')'. Do you agree I placed them properly? }}

that's it.
but before that, if don't mind, please ansewer my first question? because we don't still make concensus on basic knowlege of some command. if we make that, i think we can make progress.
1. Nyquist never creates tracks. Tracks (by definition) are items in Audacity's window and Audacity's project.
Therefore you do not create tracks by your scripts.
2. Neither you created any sounds. Sounds are objects shared by Audacity and Nyquist.
But from your scripts, Audacity recieves no sounds (no audio data). Did you test? Am I right?

Please do not forget to put some your plugin or two of them. Some easy ones if you wish. Then we can proceed further.

jan.kolar
Posts: 273
Joined: Sat May 24, 2008 7:01 pm
Operating System: Please select

Re: bug? my fault? makearray won't work.

Post by jan.kolar » Thu May 29, 2008 2:10 pm

You wrote.
Volta-X wrote:aw? i already put up plugin script in 3 or 4 patters above? isnt that enough?
ok i put up'em again.

Code: Select all

;nyquist plug-in
;version 1
;type process
;name "mono"
;action ""
;info "
s
or

Code: Select all

;nyquist plug-in
;version 1
;type process
;name "mono"
;action ""
;info "
(setf s (make-array 2)) s
or

Code: Select all

;nyquist plug-in
;version 1
;type process
;name "mono"
;action ""
;info "
(setf s (make-array 2)) (vector s s)
Therefore I had to say the second "yes".

jan.kolar
Posts: 273
Joined: Sat May 24, 2008 7:01 pm
Operating System: Please select

Re: bug? my fault? makearray won't work.

Post by jan.kolar » Sat May 31, 2008 8:41 am

Audacity documentation defines stereo sound as an array of two sounds. Is (vector NIL NIL) a sound? Sctrictly speaking, not. So, the issue you say "solved by devellopers" is the following: (Non-audacity) Nyquist users are used to call that sound, while Audacity does not consider that sound. (You may check yourself, if mult, cue, and seq do accept NILs as sound or not.)
If you are writing your own script, it should not be a big issue for you. The problem could appear when a user without Nyquist programming skills needs to use a plugin that rellay's on accepting NILs as sounds. Severity of this problem
however depends whether Nyquist functions lie seq accept NILs. Do they?

As you found out already yourself, only one of the three codes you supplied is a *working* Audacity pluggin. Indeed the trivial one with 's'. So if this is the effect used for both left and right channels, the solution can already be found in the old postings.
cue function is needed for that, which I observed when trying it. That means I learned something about nyquist. I learned also something about poeple, by the way.

You do not need make make-array work. It does work and makes arrays always. Arrays of NILs. After you learn what aref does, you will uderstand how to make it array of sounds. You were using aref many times in your scripts, did not you?
I do not know if make-array can be made to work for you.

Locked