From: Steve the Fiddle <stevethefiddle@gm...>  20091224 15:24:22
Attachments:
Message as HTML

;nyquist plugin ;version 2 ;type process ;categories "http://lv2plug.in/ns/lv2core#MixerPlugin"; ;name "Cross Fade In" ;action "CrossFading In..." (mult s (controlsrateabs *soundsrate* (sndexp (sndscale 0.5 (sndlog (ramp)))))) 
From: edgar <edgarrft@we...>  20091224 19:19:15

Hi Steve, I'm sorry to tell but your fix doesn't solve the problem, it only reduces the 'click' noise to one sample, but the click still exists. The reason for the 'click' is not the lower sample frequency of *controlsrate*, instead it's caused by the Nyquist 'ramp' function. From the Nyquist manual: > (ramp [duration]) > > The function actually reaches 1 at 'duration', and therefore > has one extra sample, making the total duration be: > > duration + 1 / *Controlsrate* (a picture how this lookslike on the sample level is included in the 'ramp' explanation in the Nyquist manual). Plain english version: Using *soundsrate*, 'ramp' reaches an envelope value of 1.0 (max) at the last sample of the Audacity sound, but then adds a zerosample, which results in a onesample click and a wrong length of the sound which is returned to Audacity. See the 'envelopes' chapter in the Nyquist manual and the explanations of the various 'pwl' functions how to construct a nonclick version.  edgar  The author of this email does not necessarily endorse the following advertisements, which are the sole responsibility of the advertiser: 
From: Stevethefiddle <stevethefiddle@gm...>  20091224 19:46:22

Hi Edgar, Thanks for checking it out. Testing it here it "appears" to solve the problem, though I was a little surprised that the is no sign of the final zero sample from (ramp). I'm using Audacity 1.3.10 on Linux and there is definitely no sign of a final zero sample. If there is a glitch on other platforms (or Audacity versions) I'll make a new version using (pwlv...) I was actually working on a crossfade effect that really does do a crossfade (alpha version is here: http://forum.audacityteam.org/download/file.php?id=1045 ) and noticed that when multiplying a control rate envelope with a sound there is often a glitch at the end (even when the envelope does not have a final zero sample). This appears to be a minor bug in Audacity  you can reproduce it easily with: (mult s (const 1)) Steve edgarrft wrote: > > Hi Steve, > > I'm sorry to tell but your fix doesn't solve the problem, it only > reduces the 'click' noise to one sample, but the click still exists. > > The reason for the 'click' is not the lower sample frequency of > *controlsrate*, instead it's caused by the Nyquist 'ramp' function. > > From the Nyquist manual: > > > (ramp [duration]) > > > > The function actually reaches 1 at 'duration', and therefore > > has one extra sample, making the total duration be: > > > > duration + 1 / *Controlsrate* > > (a picture how this lookslike on the sample level is included in > the 'ramp' explanation in the Nyquist manual). > > Plain english version: > > Using *soundsrate*, 'ramp' reaches an envelope value of 1.0 (max) at > the last sample of the Audacity sound, but then adds a zerosample, > which results in a onesample click and a wrong length of the sound > which is returned to Audacity. > > See the 'envelopes' chapter in the Nyquist manual and the explanations > of the various 'pwl' functions how to construct a nonclick version. > >  edgar > > > > >  > The author of this email does not necessarily endorse the following > advertisements, which are the sole responsibility of the advertiser: > > >  > This SF.Net email is sponsored by the Verizon Developer Community > Take advantage of Verizon's bestinclass app development support > A streamlined, 14 day to market process makes app distribution fast and > easy > Join now and get one step closer to millions of Verizon customers > http://p.sf.net/sfu/verizondev2dev > _______________________________________________ > Audacitynyquist mailing list > Audacitynyquist@... > https://lists.sourceforge.net/lists/listinfo/audacitynyquist > >  View this message in context: http://n2.nabble.com/Crossfadeinnytp4213515p4214405.html Sent from the audacitynyquist mailing list archive at Nabble.com. 
From: edgar <edgarrft@we...>  20091224 22:19:24

Tested with Audacity CVS HEAD on Ubuntu 9.10 (Gnome): In Audacity CVS HEAD, the last sample seems not to be zero, but 'ramp' returns definetly one sample more than selected. In Audacity I generate a squarewave track via "Generate > Tone" (In the "horizontal" part of a square wave I can see the bug better than in a sine wave, you cold also use a "const" DCoffset signal for testing.) I zoom in until I can see the sample points and select ten samples. I open "Effect > Nyquist Prompt" and copy Steve's code into the editor window: (mult s (controlsrateabs *soundsrate* (sndexp (sndscale 0.5 (sndlog (ramp)))))) After clicking OK Nyquist returns ELEVEN samples (not TEN as I had selected), and in Audacity all samples after the selection get shifted one sample to the right, destroying the phase alignment of the Audacity tracks. If you want to see the 'ramp' very clear then select approx. ten samples in the "horizontal" part of the negative halvewave of a squarewave and apply the following code via the Audacity Nyquist prompt: (controlsrateabs *soundsrate* (ramp)) This needs still to be tested on Windows and Mac.  edgar 
From: Stevethefiddle <stevethefiddle@gm...>  20091225 01:53:23

edgarrft wrote: > > > Tested with Audacity CVS HEAD on Ubuntu 9.10 (Gnome): > > In Audacity CVS HEAD, the last sample seems not to be zero, but > 'ramp' returns definetly one sample more than selected. > > In Audacity I generate a squarewave track via "Generate > Tone" > > (In the "horizontal" part of a square wave I can see the bug better > than in a sine wave, you cold also use a "const" DCoffset signal > for testing.) > > I zoom in until I can see the sample points and select ten samples. > > I open "Effect > Nyquist Prompt" and copy Steve's code into the > editor window: > > (mult s (controlsrateabs *soundsrate* > (sndexp (sndscale 0.5 (sndlog (ramp)))))) > > After clicking OK Nyquist returns ELEVEN samples (not TEN as I had > selected), and in Audacity all samples after the selection get > shifted one sample to the right, destroying the phase alignment of > the Audacity tracks. > That's another issue which I raised a long time ago. There is an "uncertainty" when selecting. If the selection goes beyond half way past the midpoint between samples on both sides of the selection, you get an extra sample. You may remember the issue (which I believe is now fixed) where you would "split" a section from the middle of a track, then use the Time Shift tool to move the last section  sometimes it would move just the last section and sometimes the middle (split) section would move with it? There is a problem when it comes to "sample accurate" processing with Nyquist, and that problem has been there for a long time. edgarrft wrote: > > If you want to see the 'ramp' very clear then select approx. ten > samples in the "horizontal" part of the negative halvewave of a > squarewave and apply the following code via the Audacity Nyquist > prompt: > > (controlsrateabs *soundsrate* (ramp)) > Yes that illustrates your point very well, but do you get a click at the end of: (mult s (controlsrateabs *soundsrate* (sndexp (sndscale 0.5 (sndlog (ramp)))))) I know that there "should" be a click, but I get no click. edgarrft wrote: > > This needs still to be tested on Windows and Mac. > >  edgar > > Roger Dannenberg wrote: > > I believe the modified fadein uses the square root of a linear ramp. > Maybe even better would be a raised cosine, which is smooth at both ends > and has the property that the fadein and fadeout curves sum to 1. > Also, there is a square root function in Nyquist that is more efficient > than taking logs and exponents, but isn't available in older versions of > Audacity. Probably in this case, efficiency is not important. Roger > I agree that efficiency is not a prime concern here. I'm not particularly keen on the curve used in this effect, but I just stayed with the existing code. For a square root of a linear ramp, perhaps this would be better? (mult s (controlsrateabs *soundsrate* (ssqrt (pwlv 0 1 1)))) There is still a minor issue of "one sample difference" (depending on exactly how far the selection extends beyond the last sample), but other than that it works. I've been playing with Bezier curves which give a lot more versatility so I'm not too concerned about spending a lot of time on this, especially as it does not do a crossfade. The Newnewcrossfade effect (mentioned in my last post) uses *scratch* to switch from fadein to fadeout (or vice verse) and uses Bezier curves rather than the square root of a linear ramp. It can produce some really smooth crossfades as well as very pretty fadeouts :=) I'm working on the interface to try and strike a nice balance between versatility and simplicity but having difficulty getting enough user feedback to know where to strike the balance. I'll post some variations on the theme in the hope of some feedback here, but for now, happy Christmas. Steve  View this message in context: http://n2.nabble.com/Crossfadeinnytp4213515p4215151.html Sent from the audacitynyquist mailing list archive at Nabble.com. 
From: paul beach <sniffyraven@fa...>  20091225 02:53:59

Is there some way of getting at the spectrum data? I have to copy it to Excel, divide by 20 and take the antilog. This makes for a rather messy procedure to find the Entropy. What does entropy mean? This application is closest to information theory. You might recall that a diminished 7th chord divides the octave, equally into minor thirds. It should, therefore, have the greatest Entropy, as below. Major Triad 4.53482001294 Dominant 7th 5.13962370587 Diminished 7th 5.33988280592  paul beach sniffyraven@... 
From: paul beach <sniffyraven@fa...>  20100112 16:22:59

This instruction to create a sum of overtones will not loop more than n = 130 times. I can't figure that out. (simrep ( i n) (hzosc (+ (* i p) p) ) ) ;nyquist plugin ;version 1 ;type generate ;name "Heartbeat ..." ;action "Overtones..." ;control p "Fundamental" real "Frequency" 3.5 1 1000 ;control n "number" int "overtones" 40 1 500 ;control q "Quality" int "resonance" 2 1 50 ;control bp "Bandpass Filter" int "center" 200 50 500 ; You can hear "muscle avalance" by putting your thumb in ; your ear, (lightly) and clenching your fist. Put your palm ; over the other ear to block out distractions. ;Realistic rythmn should be loudsoftsilence where loud = +6dB (scale 0.1 (bandpass2 (simrep ( i n) (hzosc (+ (* i p) p) ) ) bp q) )  paul beach sniffyraven@... 
From: Roger Dannenberg <rbd@cs...>  20100112 17:31:29

XLISP has some stack and recursion limitations. SIMREP is a macro. I'm not sure what's going on, but 130 seems to be the right order of magnitude to be hitting some stack limits. You can write a loop that repeatedly sets a local variable holding a sound to the sum of the sound and another sound. This should accumulate sounds without growing the stack. Roger paul beach wrote: > This instruction to create a sum of overtones will not loop more than n > = 130 times. I can't figure that out. > > (simrep ( i n) > (hzosc (+ (* i p) p) ) > ) > > > ;nyquist plugin > ;version 1 > ;type generate > ;name "Heartbeat ..." > ;action "Overtones..." > ;control p "Fundamental" real "Frequency" 3.5 1 1000 > ;control n "number" int "overtones" 40 1 500 > ;control q "Quality" int "resonance" 2 1 50 > ;control bp "Bandpass Filter" int "center" 200 50 500 > > ; You can hear "muscle avalance" by putting your thumb in > ; your ear, (lightly) and clenching your fist. Put your palm > ; over the other ear to block out distractions. > > ;Realistic rythmn should be loudsoftsilence where loud = +6dB > > (scale 0.1 > (bandpass2 > (simrep ( i n) > (hzosc (+ (* i p) p) ) > ) > bp q) > ) > 
From: Steve the Fiddle <stevethefiddle@gm...>  20100112 20:32:23

Roger Dannenberg wrote: > XLISP has some stack and recursion limitations. SIMREP is a macro. I'm > not sure what's going on, but 130 seems to be the right order of > magnitude to be hitting some stack limits. You can write a loop that > repeatedly sets a local variable holding a sound to the sum of the sound > and another sound. This should accumulate sounds without growing the > stack. Roger > > paul beach wrote: > >> This instruction to create a sum of overtones will not loop more than n >> = 130 times. I can't figure that out. >> >> (simrep ( i n) >> (hzosc (+ (* i p) p) ) >> ) >> >> >> ;nyquist plugin >> ;version 1 >> ;type generate >> ;name "Heartbeat ..." >> ;action "Overtones..." >> ;control p "Fundamental" real "Frequency" 3.5 1 1000 >> ;control n "number" int "overtones" 40 1 500 >> ;control q "Quality" int "resonance" 2 1 50 >> ;control bp "Bandpass Filter" int "center" 200 50 500 >> >> ; You can hear "muscle avalance" by putting your thumb in >> ; your ear, (lightly) and clenching your fist. Put your palm >> ; over the other ear to block out distractions. >> >> ;Realistic rythmn should be loudsoftsilence where loud = +6dB >> >> (scale 0.1 >> (bandpass2 >> (simrep ( i n) >> (hzosc (+ (* i p) p) ) >> ) >> bp q) >> ) Yes, I'm seeing a stack overflow error. Try something like: (setq newsound (srest)) ; initialise newsound (setq newsound (dotimes (i n newsound) ; return newsound (setq newsound (sim newsound (hzosc (+ (* i p) p)))))) (setq newsound (bandpass2 newsound bp q)) ; filter (mult (/ 1.0 (peak newsound (truncate *soundsrate*))) newsound) ; normalise Steve D 
From: paul beach <sniffyraven@fa...>  20100117 09:30:12

Yes, everything works. I specified p as real in the ;control section. Apparently this is not sufficient to assure a float in the body of the program. (below) There was a discussion: "The digits shift in the query boxes??" I should have paid attention to it. Also, in the previous Email, I suggested that the sum of the squares would create the "normal modes" of a square surface. Not true: It the square root of the sum of squares on the upper diagonal of the matrix. for i for j if j <= i array_element = sqrt( i^2 + j^2) ;nyquist plugin ;version 1 ;type generate ;name "Heartbeat ver 1 ..." ;action "Overtones..." ;control p "Fundamental" real "Frequency" 25 0.01 100 ;control n "number" int "overtones" 140 1 500 ;control q "Quality" int "resonance" 10 1 50 ;control bp "Bandpass Filter" int "center" 130 50 500 (setq newsound (srest)) ; initialise newsound (setq newsound (dotimes (i n newsound) ; return newsound (setq newsound (sim newsound (hzosc (+(sqrt (* (float p) i)) p)))))) (setq newsound (bandpass2 newsound bp q)) ; filter ;(scale 0.075 (seq (srest 0.25) newsound (srest 0.25))) (seq (srest 0.25) (mult (/ 1.0 (peak newsound (truncate *soundsrate*))) newsound) (srest 0.25))  paul beach sniffyraven@... 
From: paul beach <sniffyraven@fa...>  20100119 10:41:28

I have a messy program to do square root of sums of squares, similar to vector distance. It seems that (float i) has to be used to make it run. It's rather bloated: (hzosc (sim (mult (sqrt (+ (* (float i) (float i)) (* (float j) (float j)) ) ) (float p) ) (srest)))))))) Can the variables be "typed" globally, or some other fix? ;nyquist plugin ;version 1 ;type generate ;name "Heartbeat ver 2 ..." ;action "Overtones..." ;control p "Fundamental" real "Frequency" 100 0.01 100 ;control n "number" int "overtones" 4 1 50 ;control q "Quality" int "resonance" 2 1 50 ;control bp "Bandpass Filter" int "center" 130 50 500 (setq newsound (srest)) ; initialise newsound (setq newsound (dotimes (i n newsound) ; return newsound (dotimes (j n) (setq newsound (sim newsound (hzosc (sim (mult (sqrt (+ (* (float i) (float i)) (* (float j) (float j)) )) (float p) ) (srest)))))))) ;(setq newsound (bandpass2 newsound bp q)) ; filter (seq (srest 0.25) (mult (/ 0.5 (peak newsound (truncate *soundsrate*))) newsound) (srest 0.25))  paul beach sniffyraven@... 
From: edgar <edgarrft@we...>  20100119 13:14:52

Paul Beach asked: > Can the variables be "typed" globally, or some other fix? Explanation: in Lisp, a variable has no type, its the variable's value which determines the type of the variable. *** General Examples (setq varname 1) Here the value (the number 1) of the variable 'varname' has a Lisp type of FIXNUM (integer number), that' the reason why: (print (typeof varname)) will print FIXNUM in the Audacity 'Debug' window, but it's the variable's value (the number '1') which determines the type, not the variable 'varname' itself. You can change the type of a variable just simply by assigning a value with a different type: (setq varname 1.0) (print (typeof varname)) will print FLONUM (floating point number), because again it's the number '1.0' which has the type FLONUM, the 'varname' as a variable name has no say about its type. *** Practical examples: ;; a variable 'varname' with a FIXNUM value (setq varname 1) (print (typeof varname)) ;; convert the FIXNUM into a FLONUM (setq varname (float varname)) (print (typeof varname)) prints in the Audacity 'Debug' window: FIXNUM FLONUM This means that a variable can change its type at runtime depending on its value. As soon as the type of the value has changed, also the type of the variable has changed. The variable itself has no type, it's the type of the value which gets returned by TYPEOF. Here is how you can use this in your code: *** DOTIMES examples: DOTIMES uses a FIXNUM (integer number) for its loop variable: (dotimes (i 4) (format t "~a/2=~a~%" i (/ i 2))) prints in the Audacity 'Debug' window: 0/2=0 1/2=0 ; wrong integer result 2/2=1 3/2=1 ; wrong integer result To fix the wrong integer results the value of 'i' must be a FLONUM inside the DOTIMES loop and not a FIXNUM, but unfortunately DOTIMES does not accept a FLONUM as its initvalue: (dotimes (i 4.0) (format t "~a/2=~a~%" i (/ i 2))) prints in the Audacity 'Debug' window: error: bad argument type  4 Function: #<FSubrDOTIMES: #b9155f4> Arguments: (I 4) (FORMAT T "~a/2=~a~%" I (/ I 2)) 1> Here is how you can make 'i' become a FLONUM (floating point number) in the body of a DOTIMES loop: (dotimes (i 4) (setq i (float i)) ; write this once at the beginning of DOTIMES (format t "~a/2=~a~%" i (/ i 2))) ; now every 'i' is of type FLONUM prints in the Audacity 'Debug' window: 0/2=0 1/2=0.5 ; correct floatingpoint result 2/2=1 3/2=1.5 ; correct floatingpoint result A possible problem could be that the SETQ line must be computed with every loop, so a faster and more general (but also more cryptic) version is using DO, because DO can also use variables with FLONUM values as loop variables: (do ((i 0.0 (1+ i))) ; start with i=0.0, add 1 to 'i' with every loop ((>= i 4) i) ; stop if i>=4, return 'i' (format t "~a/2=~a~%" i (/ i 2))) ; every 'i' is of type FLONUM displays '5.0' (the DO return value) in the Audacity popup window, and prints in the Audacity 'Debug' window: 0/2=0 1/2=0.5 ; correct floatingpoint result 2/2=1 3/2=1.5 ; correct floatingpoint result A FIXNUM (integer) DO loop, imitating DOTIMES, would look like this: (do ((i 0 (1+ i))) ; start with i=0, add 1 to 'i' with every loop ((>= i 4) i) ; stop if i>=4, return 'i' (format t "~a/2=~a~%" i (/ i 2))) ; every 'i' is of type FIXNUM displays '5' (the DO return value) in the Audacity popup window, and prints in the Audacity 'Debug' window: 0/2=0 1/2=0 ; wrong integer result 2/2=1 3/2=1 ; wrong integer result Hope this helps a bit ...  edgar  The author of this email does not necessarily endorse the following advertisements, which are the sole responsibility of the advertiser: 
From: Roger Dannenberg <rbd@cs...>  20100119 14:32:11

No, you cannot eliminate FIXNUMs. In principle, you can write your own DOTIMES macro to use FLONUMs (but DOTIMES is an XLISP primitive; a macro would be slower). Also, unless you are worried about integer overflow (XLISP FIXNUMs are 32 bit signed integers, at least on 32bit architectures), the only issue in your example is that SQRT requires a FLONUM, so you could just write (* (sqrt (float (+ (* i i) (* j j) p). This will always return a FLONUM. Finally, since SQRT is the function giving you problems, you can write your own version that takes FIXNUMs or FLONUMs: (defun sqrti (x) (sqrt (float x))). Roger paul beach wrote: > I have a messy program to do square root of sums of squares, similar to > vector distance. It seems that (float i) has to be used to make it run. > It's rather bloated: > > (hzosc (sim (mult (sqrt (+ (* (float i) (float i)) (* (float j) > (float j)) ) ) (float p) ) (srest)))))))) > > Can the variables be "typed" globally, or some other fix? > > ;nyquist plugin > ;version 1 > ;type generate > ;name "Heartbeat ver 2 ..." > ;action "Overtones..." > ;control p "Fundamental" real "Frequency" 100 0.01 100 > ;control n "number" int "overtones" 4 1 50 > ;control q "Quality" int "resonance" 2 1 50 > ;control bp "Bandpass Filter" int "center" 130 50 500 > > (setq newsound (srest)) ; initialise newsound > > (setq newsound > (dotimes (i n newsound) ; return newsound > (dotimes (j n) > (setq newsound (sim newsound > (hzosc (sim (mult (sqrt (+ (* (float i) (float i)) (* (float > j) (float j)) )) (float p) ) (srest)))))))) > > ;(setq newsound (bandpass2 newsound bp q)) ; filter > > > (seq (srest 0.25) (mult (/ 0.5 (peak newsound (truncate > *soundsrate*))) > newsound) (srest 0.25)) > 
From: paul beach <sniffyraven@fa...>  20100122 01:02:01

The Nyquist Plugin, 'Normal Modes of a Square' is done. This is a big topic, a few details are mentioned here: http://www.climatehoax.ca/music/ A cow bell has a square face, a few tinkles from the plugin are put together here: http://www.climatehoax.ca/music/cow.mp3 Certain prime numbers are sums of squares. A prime number of the form 4k + 3 CANNOT be a sum of squares. A property of a square is that it cannot have a mode frequency of sqrt(11). The default frequency multiplier is 1000hz, make sure it is not 999. You will get these spectra results: sqrt(13)*1000 = 3605.55 hz Amplitude = 0.57 dB sqrt(11)*1000 = 3316.6 hz Amplitude = 66.6 dB The difference is 66dB. AudacityNyquist can do Array operations on any number of sine waves. To do this with a spectrum analyser with computer link might cost a hundred thousand dollars. I am doing it on a 100Mhz computer with the help of Steve's program. Note that the loop must start with ,1 rather than 0. See nested IF statements. ;nyquist plugin ;version 1 ;type generate ;name "Normal Modes of a Square ver 1.0 ..." ;action "Overtones..." ;info "by Paul Beach, Audacity Discussion List" ;control p "Multiply by" real "Frequency" 1000.0 10 9000 ;control n "Number of" int "Nodes  1" 4 1 50 (setq newsound (srest)) ; initialise newsound (setq newsound (dotimes (i n newsound) ; return newsound (dotimes (j n ) (setq i (float i)) (setq p (float p)) (setq j (float j)) (if ( /= j 0.0 ) (if ( /= i 0.0) (if (<= j i) (setq newsound (sim newsound (hzosc (sim (* (sqrt (+ (* i i ) (* j j ))) p ) (srest))))))))))) (setq newsound (mult (expdec 0 0.1 1) newsound )) ; filter (seq (srest 0.05) (mult (/ 0.95 (peak newsound (truncate *soundsrate*))) newsound) (srest 0.05))  paul beach sniffyraven@... 
From: paul beach <sniffyraven@fa...>  20100126 14:07:04

I can't seem to stretch my "newsound", in this case, to 1.5 secounds. The stretch is the only part of expdec that won't work. (setq newsound (mult (expdec 0 0.15 1.5) newsound )) ; decay  paul beach sniffyraven@... 
From: Roger Dannenberg <rbd@cs...>  20100126 14:40:46

Stretch is a special form that alters the execution environment so that the default duration of a sound is "stretched" by a factor. Whether or not the expression that is "stretched" behaves according to the environment is up to the expression and not enforced. In particular, a variable just evaluates to the value that was assigned to it. If newsound is bound to a sound, then (stretch 2.0 newsound) just returns the sound without any change because variable evaluation ignores the environment. Roger paul beach wrote: > I can't seem to stretch my "newsound", in this case, to 1.5 secounds. > The stretch is the only part of expdec that won't work. > > (setq newsound (mult (expdec 0 0.15 1.5) newsound )) ; decay > 
From: paul beach <sniffyraven@fa...>  20100129 03:45:29

I am using autocorrelation, which gives frequencies lower than the fundamental. This does not seem to be useful, for the business at hand. The spectrum of this Music box sample is checked for normal modes. http://www.climatehoax.ca/music/880_music_box.mp3 Where the modes are present, the array entries are colored. http://www.climatehoax.ca/music/music_box_normal_modes.gif The symetry is quite striking, but it does not prove anything. Does anybody have suggestions for a statistical analysis?  paul beach sniffyraven@... 
From: paul beach <sniffyraven@fa...>  20100130 22:31:39

Steve and Edgar mention problems with a large data base. In particular, finding the peak of a Gigabyte file. If the file is in a hex editor, XOR each word with FFFF. Your peak is the highest bit that gets knocked out, plus an extra 3dB. C has reasonable access to the CPU register logic, and that is the usual way of doing it, or sometimes with hardware. I don't see XOR in the Nyquist documents, just AND, OR. If you are doing Public Key Encryption, CD error correction, satellite communications, then the arithmetic has to be done by logic, mostly XOR (exclusive Or) and shift registers. Otherwise, you wait until the "end of days" for your result. I did 100 million XOR operations on a 1.8 Ghz computer. It took 13 seconds; most of the time is probably spent with loop overhead. Sub logic_f() ' 2^16 = 65536 = 0000 0000 0000 0000 1 = 00001 ' 2^16  1 = 65535 = 1111 1111 1111 1111 = FFFF (2 bytes) Dim x_big As Long ' 4 byte +/ signed integer Dim x_small As Long x_big = 65535 x_small = 65534 For i = 1 To 100000000 ' 100 million = 100 000 000 xn = x_small Xor x_big ' result = 12 seconds @1.8Ghz Next i Cells(1, 1) = xn ' output = 1 End Sub  paul beach sniffyraven@... 
From: Roger Dannenberg <rbd@cs...>  20100131 16:08:38

Paul, That's a very interesting algorithm that I haven't seen or thought about. You're getting an Xor operation about every 18 cycles. To find a peak over many samples, you need to combine the xor results, but this can be done with AND  the AND of all the XOR results will have a zero bit anywhere there was at least one zero bit in an XOR result. Nyquist has a LOGXOR function, but this would be at least 100 times slower than using builtin signal processing operations like PEAK because signal processing primitives are written in compiled C and access signal data directly, whereas Nyquist is interpreted and must convert signal data to XLISP floats, which are allocated on the heap. This implies memory allocation, copying, and garbage collection. However, all this assumes positive integers, while Nyquist audio samples are positive and negative, and they are floats. If you really want fast peak finding on Intel hardware, the SSE MAXSP instruction will take the max of 4 floats in a single instruction. You would need to find the max over both x and x values if you want the maximum of the absolute values of samples. The real issue right now seems to be not the inner loop details but whether Nyquist is keeping signal samples in RAM or throwing them out. In principle, Nyquist should be able to compute peaks without retaining the audio samples, but I gather from other posts this is not happening. I'm not sure why and plan to look at it, although I'm swamped with other work for a month or so. Roger paul beach wrote: > Steve and Edgar mention problems with a large data base. > In particular, finding the peak of a Gigabyte file. > > If the file is in a hex editor, XOR each word with FFFF. Your peak is > the highest bit that gets knocked out, plus an extra 3dB. C has > reasonable access to the CPU register logic, and that is the usual way > of doing it, or sometimes with hardware. > > I don't see XOR in the Nyquist documents, just AND, OR. > > If you are doing Public Key Encryption, CD error correction, satellite > communications, then the arithmetic has to be done by logic, mostly XOR > (exclusive Or) and shift registers. Otherwise, you wait until the "end > of days" for your result. > > I did 100 million XOR operations on a 1.8 Ghz computer. It took 13 > seconds; most of the time is probably spent with loop overhead. > > Sub logic_f() > > ' 2^16 = 65536 = 0000 0000 0000 0000 1 = 00001 > ' 2^16  1 = 65535 = 1111 1111 1111 1111 = FFFF (2 bytes) > > Dim x_big As Long ' 4 byte +/ signed integer > Dim x_small As Long > > x_big = 65535 > x_small = 65534 > > For i = 1 To 100000000 ' 100 million = 100 000 000 > xn = x_small Xor x_big ' result = 12 seconds @1.8Ghz > Next i > > Cells(1, 1) = xn ' output = 1 > > End Sub > 
From: paul beach <sniffyraven@fa...>  20100115 13:52:19

The fix for stack overflow works on my windows 98 with a broken mouse. It is changed slightly to a sum of square roots. Perhaps a square membrane will vibrate in this way, I have to check. The addition of silence to the beginning and end caused the plugin to crash, so I commented out the last line to normalise. ;nyquist plugin ;version 1 ;type generate ;name "Heartbeat ver 1 ..." ;action "Overtones..." ;control p "Fundamental" real "Frequency" 25 0.01 100 ;control n "number" int "overtones" 140 1 500 ;control q "Quality" int "resonance" 10 1 50 ;control bp "Bandpass Filter" int "center" 130 50 500 (setq newsound (srest)) ; initialise newsound (setq newsound (dotimes (i n newsound) ; return newsound (setq newsound (sim newsound (hzosc (+(sqrt (* p i)) p)))))) (setq newsound (bandpass2 newsound bp q)) ; filter (scale 0.075 (seq (srest 0.25) newsound (srest 0.25))) ;(mult (/ 1.0 (peak newsound (truncate *soundsrate*))) newsound)  paul beach sniffyraven@... 
From: Stevethefiddle <stevethefiddle@gm...>  20100115 19:59:54

Are you sure that the crash is due to normalizing? I'm getting a "bad integer operation" error if "p" is a whole number. This can be resolved by forcing p to be float: (setq newsound (srest)) ; initialise newsound (setq newsound (dotimes (i n newsound) ; return newsound (setq newsound (sim newsound (hzosc (+(sqrt (* (float p) i)) p)))))) (setq newsound (bandpass2 newsound bp q)) ; filter (seq (srest 0.25) (mult (/ 1.0 (peak newsound (truncate *soundsrate*))) newsound) (srest 0.25)) I've added normalizing back in as it keeps the output at a good level irrespective of what parameters are used. Steve D paul beach2 wrote: > > The fix for stack overflow works on my windows 98 with a broken mouse. > It is changed slightly to a sum of square roots. Perhaps a square > membrane will vibrate in this way, I have to check. The addition of > silence to the beginning and end caused the plugin to crash, so I > commented out the last line to normalise. > > > ;nyquist plugin > ;version 1 > ;type generate > ;name "Heartbeat ver 1 ..." > ;action "Overtones..." > ;control p "Fundamental" real "Frequency" 25 0.01 100 > ;control n "number" int "overtones" 140 1 500 > ;control q "Quality" int "resonance" 10 1 50 > ;control bp "Bandpass Filter" int "center" 130 50 500 > > (setq newsound (srest)) ; initialise newsound > > (setq newsound > (dotimes (i n newsound) ; return newsound > (setq newsound (sim newsound (hzosc (+(sqrt (* p i)) p)))))) > > (setq newsound (bandpass2 newsound bp q)) ; filter > > (scale 0.075 (seq (srest 0.25) newsound (srest 0.25))) > ;(mult (/ 1.0 (peak newsound (truncate *soundsrate*))) newsound) >  > paul beach > sniffyraven@... > > >  > Throughout its 18year history, RSA Conference consistently attracts the > world's best and brightest in the field, creating opportunities for > Conference > attendees to learn about information security's most important issues > through > interactions with peers, luminaries and emerging and established > companies. > http://p.sf.net/sfu/rsaconfdev2dev > _______________________________________________ > Audacitynyquist mailing list > Audacitynyquist@... > https://lists.sourceforge.net/lists/listinfo/audacitynyquist > >  View this message in context: http://n2.nabble.com/Crossfadeinnytp4213515p4400896.html Sent from the audacitynyquist mailing list archive at Nabble.com. 
From: paul beach <sniffyraven@fa...>  20100205 16:29:59

The rediscovery below, might give the impression that there is a faster way of doing computer arithmetic. Not true, the bits and cycles are all accounted for. As Roger points out, the Intel chip even comes with a peak detector. I am having a problem, going from programs where it is effortless to use an arrayand then to Nyquist. The "list" holds frequency, amplitude, phase, endless defaults and behavious. The next step up is to set up arrays and vectors. Otherwise my programs become more messy and less flexible. Rediscovery of what?? Exclusive OR (more generally intersection) is a direct product Group. What I describe is how the C2 x C2 x C2 ... group it fits into it's largest quotient group. It is quite natural, though incorrect, to confuse this will half/full adders, which is a Ring. This is the question. "Is there a standard way of expressing vectors and arrays; which at the same time, holds the 'list' of frequency and time parameters?" If you think about my example, how the FF mask lights up in a few billionths of a second; then you are retracing the steps of quantum mechanics pioneers, back in the 1920's. I showed that an upper diagonal matrix can represent the normal modes of a matix. But this is just the tip of the iceberg. pb On Sun, 31 Jan 2010 11:08:23 0500, "Roger Dannenberg" <rbd@...> said: > Paul, > That's a very interesting algorithm that I haven't seen or thought > about. > You're getting an Xor operation about every 18 cycles. To find a > peak over many samples, you need to combine the xor results, but this > can be done with AND  the AND of all the XOR results will have a zero > bit anywhere there was at least one zero bit in an XOR result. Nyquist > has a LOGXOR function, but this would be at least 100 times slower than > using builtin signal processing operations like PEAK because signal > processing primitives are written in compiled C and access signal data > directly, whereas Nyquist is interpreted and must convert signal data to > XLISP floats, which are allocated on the heap. This implies memory > allocation, copying, and garbage collection. > However, all this assumes positive integers, while Nyquist audio > samples are positive and negative, and they are floats. If you really > want fast peak finding on Intel hardware, the SSE MAXSP instruction will > take the max of 4 floats in a single instruction. You would need to find > the max over both x and x values if you want the maximum of the > absolute values of samples. > The real issue right now seems to be not the inner loop details but > whether Nyquist is keeping signal samples in RAM or throwing them out. > In principle, Nyquist should be able to compute peaks without retaining > the audio samples, but I gather from other posts this is not happening. > I'm not sure why and plan to look at it, although I'm swamped with other > work for a month or so. > > Roger > > > > paul beach wrote: > > Steve and Edgar mention problems with a large data base. > > In particular, finding the peak of a Gigabyte file. > > > > If the file is in a hex editor, XOR each word with FFFF. Your peak is > > the highest bit that gets knocked out, plus an extra 3dB. C has > > reasonable access to the CPU register logic, and that is the usual way > > of doing it, or sometimes with hardware. > > > > I don't see XOR in the Nyquist documents, just AND, OR. > > > > If you are doing Public Key Encryption, CD error correction, satellite > > communications, then the arithmetic has to be done by logic, mostly XOR > > (exclusive Or) and shift registers. Otherwise, you wait until the "end > > of days" for your result. > > > > I did 100 million XOR operations on a 1.8 Ghz computer. It took 13 > > seconds; most of the time is probably spent with loop overhead. > > > > Sub logic_f() > > > > ' 2^16 = 65536 = 0000 0000 0000 0000 1 = 00001 > > ' 2^16  1 = 65535 = 1111 1111 1111 1111 = FFFF (2 bytes) > > > > Dim x_big As Long ' 4 byte +/ signed integer > > Dim x_small As Long > > > > x_big = 65535 > > x_small = 65534 > > > > For i = 1 To 100000000 ' 100 million = 100 000 000 > > xn = x_small Xor x_big ' result = 12 seconds @1.8Ghz > > Next i > > > > Cells(1, 1) = xn ' output = 1 > > > > End Sub > > > >  > The Planet: dedicated and managed hosting, cloud storage, colocation > Stay online with enterprise data centers and the best network in the > business > Choose flexible plans and management services without longterm contracts > Personal 24x7 support from experience hosting pros just a phone call > away. > http://p.sf.net/sfu/theplanetcom > _______________________________________________ > Audacitynyquist mailing list > Audacitynyquist@... > https://lists.sourceforge.net/lists/listinfo/audacitynyquist  paul beach sniffyraven@... 
From: edgar <edgarrft@we...>  20100206 10:41:15

Hi Paul, The standard XLISP array and vector functions (including examples) are: makearray  allocate a new array http://www.audacityforum.de/download/edgar/nyquist/nyquistdoc/xlisp/xlispref/xlispref162.htm vector  allocate a new vector http://www.audacityforum.de/download/edgar/nyquist/nyquistdoc/xlisp/xlispref/xlispref296.htm setf  set an element of a sequence (including arrays and vectors) http://www.audacityforum.de/download/edgar/nyquist/nyquistdoc/xlisp/xlispref/xlispref238.htm aref  get an element of a sequence (including arrays and vectors) http://www.audacityforum.de/download/edgar/nyquist/nyquistdoc/xlisp/xlispref/xlispref029.htm > This is the question. "Is there a standard way of expressing vectors > and arrays; which at the same time, holds the 'list' of frequency and > time parameters?" You can make every element of an array any Lisp type you like:  Lisp code  ;; make an array of three elements (setq myarray (makearray 3)) ;; assign a list to myarray element 0 (setf (aref myarray 0) '(a b c)) ;; assign a number to myarray element 1 (setf (aref myarray 1) 123) ;; assign a string to myarray element 2 (setf (aref myarray 2) "this is a string") ;; print the elements of myarray (print (aref myarray 0)) ;; prints: (A B C) (print (aref myarray 1)) ;; prints: 123 (print (aref myarray 2)) ;; prints: "this is a string" ;; print the entire array ;; (not recommended with huge arrays) (print myarray) ;; prints: #((A B C) 123 "this is a string")  end of Lisp code  Arrays and vectors in XLISP both are onedimensional, but vectors can have initvalues, see the 'vector' HTMLlink above for examples. Array and vector elements behave like symbols, they have no type, so they can change their type at runtime, dependeding on their values. *** MultiDimensional XLISP Arrays The only way in XLISP to create multidimensional arrays is using "arrays within arrays" like this:  Lisp code  ;; first I make a onedimensional array of three elements (setq myarray (makearray 3)) ;; then I create a threedimensional array ;; with 10 elements in each dimension (dotimes (i 3) (setf (aref myarray i) (makearray 10))) (print myarray) ;; prints: #(#(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL) ;; #(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL) ;; #(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) ;; But setting and getting element values starts to become complicated: ;; set the third element in the first dimension ;; NOTE that arrays and vectors start counting with zero (setf (aref (aref myarray 0) 2) 'YES) (print myarray) ;; prints: #(#(NIL NIL YES NIL NIL NIL NIL NIL NIL NIL) ;; #(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL) ;; #(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) ;; In such a case it's easier to write explicit accessor functions: (defun setarray (dimension element value) (setf (aref (aref myarray dimension) element) value)) (defun getarray (dimension element) (aref (aref myarray dimension) element))  end of Lisp code  *** BitTwiddeling with XLISP DISCLAIMER: XLISP is an INTERPRETED Lisp with the speed of oldschool BASIC! (but to say it loud: it's much more sophisticated than BASIC) Bittwiddeling on the XLISP level is VERY slow, it would be MUCH faster to implement the desired functions in C and add them to the XLISP interpreter. However, here are the bitwise XLISP functions: logand  the bitwise AND http://www.audacityforum.de/download/edgar/nyquist/nyquistdoc/xlisp/xlispref/xlispref153.htm logior  the bitwise INCLUSIVE OR http://www.audacityforum.de/download/edgar/nyquist/nyquistdoc/xlisp/xlispref/xlispref154.htm logxor  the bitwise EXCLUSIVE OR http://www.audacityforum.de/download/edgar/nyquist/nyquistdoc/xlisp/xlispref/xlispref156.htm lognot  the bitwise NOT http://www.audacityforum.de/download/edgar/nyquist/nyquistdoc/xlisp/xlispref/xlispref155.htm *** XLISP Docs Download You can download all the XLISP docs for offlinebrowsing on this page: http://www.audacityforum.de/download/edgar/nyquist/nyquistdoc/xlisp/xlispindex.htm Have fun,  edgar  The author of this email does not necessarily endorse the following advertisements, which are the sole responsibility of the advertiser: 
From: Roger Dannenberg <rbd@cs...>  20100206 16:30:02

In addition, see the demos/fft_tutorial.htm file in Nyquist for examples of using arrays to manipulate spectral data. Also, while it's true that Nyquist is interpreted with the speed of oldschool BASIC, I prefer to say it is interpreted with the speed of Python, Perl, and Matlab :) Not to mention that oldschool BASIC on a modern processor is pretty zippy. Back to Nyquist and arrays, it might help to think about sounds as arrays of floats with optimization for streaming. If you can get by using sounds, things will run much faster and generally be much more compact to express. E.g. the PEAK function is much simpler and faster than a loop over an array, even using tricks like the XOR one Paul mentioned. Roger edgar wrote: > Hi Paul, > > The standard XLISP array and vector functions (including examples) are: > > ... > 
From: paul beach <sniffyraven@fa...>  20100208 04:04:06

Can a plugin: increment midi numbers and write, say, 60 wave samples to a fileor that Windows Temp file? (about 10 Megabytes) It is quite chore to save a sample for each midi note. Then, use it in my MIDI editor, only to find out the filter is choking the sound. Also, I see .pcm in the 'Piano' demo for the commandline Nyquist. Does that mean the program gets the sound from a table, rather than synthesize it? Will study vectors and arrays, that Edgar posted. The idea is to calculate the amplitude for each sine, and hold it in an array. Next run another loop which adds the sines and their amplitudes. dotimes ;; something like this (* amplitude(i) (hzosc (* i fundamental_frequency))) I suspect that a double loop with sines, and everything but the kitchen sink, will run SLOW. You might think, why make such a fuss over the amplitude. I need a matrix for the single sidebands, another matrix for quadratic matrix. Multiply them together, see what they look like on the spreadsheet. Upper single sidebands??? If the formant frequency is the carrier, how else would the information be encoded/decoded? pb  paul beach sniffyraven@... 