|
|
|
mszlazak
|
I posted something similar on an Audacity forum but was referred to Appendix 1 on extending Nyquist with C programming.
Since programming is a hobby and I don't know C or Lisp I thought a Nyquist-Lisp type solution might be easier but I'm not sure. Here is what I need. Say f(i) is a function of sampling index i and f(i) is fully defined on just 15 index values. Specifically, f(i) = 27/16(i^3 + 2i^2 + i) for i = -7 to 7. Now, there is some sound signal s(j) where j is it's sampling index. I wanted to form a new sound signal n(j) by summing the multiplied pairs f(i)s(j+i) for i = -7 to +7 for each possible j. f(-7)s(j-7) f(-6)s(j-6) f(-5)s(j-5) ... f(6)s(j+6) f(7)s(j+7) -------------- SUM the above to give a single value of n at some value of index j. -------------- Furthermore, I want to do this across all possible values of j for signal s to form the new signal n. Nyquist has some filter functions but none are cubic and I don't see a way to specify ones own filter function that would do what I want. How do you set this thing up? Thanks. ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
||||||||||||||||
|
Roger Dannenberg
|
Some javascript/style in this post has been disabled (why?)
Here's a high-level view and answer:What you are computing is called convolution. Convolution is a common way to implement an FIR filter. In Nyquist, convolution by a short signal like f(i) is implemented efficiently by CONVOLVE. You can construct a signal like f(i) using SND-FROM-ARRAY, and you can construct an array by allocating a new one using MAKE-ARRAY and filling in the values with SETF, or you can call VECTOR to create and initialize an array from arguments. Nyquist signals are indexed by non-negative time, not by integers, so you will have to map your problem to the time domain and think about boundary conditions -- you didn't say what is the origin (initial index) of the input or output signals. You might have to pad with zeros or remove some result samples to get the result you want. When you construct a signal to represent f(i), give it the same sample rate as s(j). -Roger [hidden email] wrote: I posted something similar on an Audacity forum but was referred to Appendix 1 on extending Nyquist with C programming. ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
||||||||||||||||
|
paul beach-2
|
http://ccrma.stanford.edu/~jos/filters/
INTRODUCTION TO DIGITAL FILTERS WITH AUDIO APPLICATIONS JULIUS O. SMITH III Center for Computer Research in Music and Acoustics (CCRMA) Department of Music, Stanford University, Stanford, California 94305 USA On Sat, 20 Jun 2009 10:13:10 -0400, "Roger Dannenberg" <[hidden email]> said: > Here's a high-level view and answer: > > What you are computing is called convolution. Convolution is a common > way to implement an FIR filter. In Nyquist, convolution by a short > signal like f(i) is implemented efficiently by CONVOLVE. You can > construct a signal like f(i) using SND-FROM-ARRAY, and you can construct > an array by allocating a new one using MAKE-ARRAY and filling in the > values with SETF, or you can call VECTOR to create and initialize an > array from arguments. Nyquist signals are indexed by non-negative time, > not by integers, so you will have to map your problem to the time domain > and think about boundary conditions -- you didn't say what is the origin > (initial index) of the input or output signals. You might have to pad > with zeros or remove some result samples to get the result you want. > When you construct a signal to represent f(i), give it the same sample > rate as s(j). > > -Roger > > [hidden email] wrote: > > I posted something similar on an Audacity forum but was referred to > > Appendix 1 on extending Nyquist with C programming. > > Since programming is a hobby and I don't know C or Lisp I thought a > > Nyquist-Lisp type solution might be easier but I'm not sure. > > Here is what I need. > > > > Say f(i) is a function of sampling index i and f(i) is fully defined > > on just 15 index values. > > > > Specifically, f(i) = 27/16(i^3 + 2i^2 + i) for i = -7 to 7. > > Now, there is some sound signal s(j) where j is it's sampling index. > > I wanted to form a new sound signal n(j) by summing the multiplied > > pairs f(i)s(j+i) for i = -7 to +7 for each possible j. > > > > f(-7)s(j-7) > > f(-6)s(j-6) > > f(-5)s(j-5) > > ... > > f(6)s(j+6) > > f(7)s(j+7) > > -------------- > > SUM the above to give a single value of n at some value of index j. > > -------------- > > Furthermore, I want to do this across all possible values of j for > > signal s to form the new signal n. > > Nyquist has some filter functions but none are cubic and I don't see a > > way to specify ones own filter function that would do what I want. > > How do you set this thing up? > > > > Thanks. > > > > ------------------------------------------------------------------------ > > Make your summer sizzle with fast and easy recipes > > <http://food.aol.com/grilling?ncid=emlcntusfood00000003> for the grill. > > ------------------------------------------------------------------------ > > > > ------------------------------------------------------------------------------ > > Are you an open source citizen? Join us for the Open Source Bridge conference! > > Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. > > Need another reason to go? 24-hour hacker lounge. Register today! > > http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > Audacity-nyquist mailing list > > [hidden email] > > https://lists.sourceforge.net/lists/listinfo/audacity-nyquist > > paul beach [hidden email] ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
||||||||||||||||
|
mszlazak
|
Hi Roger,
First, thank you for the tips. The documentation in Nyquists functions for CONVOLVE is sparse. I'll need to research this one a bit more. I was going to approach things by sample indexes where I changed the sound s to an array using SND-FETCH or SND-FETCH-ARRAY and proceed with f(i). But I do see that your suggestion maybe easier. When using convolve with a signal-of-f(i) and s, since f(i) is short (15 samples) then does f(i) have to be repeat over and over (at s's sampling rate) in the creation of the signal-of-f(i) to make it the same length as the sound signal s? I was wondering about boundary conditions. I thought I would create the new signal from however many 15 sample "windows" I got from the original signal. This shortens the new signal. Your zero-padding suggestion does not shorten the new signal. Is zero-padding what's used in Nyquist's function to calculate RMS values of some signal and is this a "standard" approach found other places? Also, any suggestion on a good (easy to understand) Lisp tutorial. Have a good day. Mark. From: paul beach <[hidden email]> To: Discussion of developing Nyquist plug-ins for Audacity <[hidden email]> Sent: Sat, Jun 20, 2009 7:58 am Subject: [Audacity-nyquist] INTRODUCTION TO DIGITAL FILTERS--Help with individual signal ... http://ccrma.stanford.edu/~jos/filters/ ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
||||||||||||||||
|
Roger Dannenberg
|
Here's an example using CONVOLVE. I'll put this in
nyquist/demos/convolve.lsp for future reference. -Roger ;; simple convolution example ;; Roger B. Dannenberg, 2009 ;; convolve a simple response with a train of impulses. ;; each impulse should turn into a copy of the simple response ;; shifted by the time of the impulse ;; for the response, I'll use a few cycles of a sine tone with a ;; smoothing window (defun response (dur freq) (mult (stretch dur (hzosc freq)) (stretch dur (raised-cosine)))) ;; from fft_tutorial.html (defun raised-cosine () (scale 0.5 (sum (const 1) (lfo (/ 1.0 (get-duration 1)) 1 *sine-table* 270)))) ;; for the signal, create some impulses (defun impulse (dur) ;; to make an impulse, make a const signal with a duration of one sample ;; const runs at the control rate by default so run in an environment ;; where the control rate is set to the current sound sample rate (seq (control-srate-abs *sound-srate* (const 1.0 (/ 0.9 *sound-srate*))) (s-rest (- dur (/ 0.9 *sound-srate*))))) (defun my-signal () (seq (impulse 0.003) (impulse 0.005) (impulse 0.003))) ;; plot the result (s-plot (convolve (my-signal) (response 0.002 2000.0)) 600 0.02) ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
||||||||||||||||
|
Stevethefiddle
|
In reply to this post
by mszlazak
On Sat, 2009-06-20 at 13:53 -0400, [hidden email] wrote:
> Hi Roger, > > First, thank you for the tips. > The documentation in Nyquists functions for CONVOLVE is sparse. I'll > need to research this one a bit more. > > I was going to approach things by sample indexes where I changed the > sound s to an array using SND-FETCH or SND-FETCH-ARRAY and proceed > with f(i). > But I do see that your suggestion maybe easier. When using convolve > with a signal-of-f(i) and s, since f(i) is short (15 samples) then > does f(i) have to be repeat over and over (at s's sampling rate) in > the creation of the signal-of-f(i) to make it the same length as the > sound signal s? > > I was wondering about boundary conditions. I thought I would create > the new signal from however many 15 sample "windows" I got from the > original signal. This shortens the new signal. > Your zero-padding suggestion does not shorten the new signal. Is > zero-padding what's used in Nyquist's function to calculate RMS values > of some signal and is this a "standard" approach found other places? > > > Also, any suggestion on a good (easy to understand) Lisp tutorial. There are examples shown for each function in the XLisp manual: http://www.audacity-forum.de/download/edgar/nyquist/nyquist-doc/xlisp/xlisp-ref/xlisp-ref-index.htm Steve > > Have a good day. > > Mark. > > > > > -----Original Message----- > From: paul beach <[hidden email]> > To: Discussion of developing Nyquist plug-ins for Audacity > <[hidden email]> > Sent: Sat, Jun 20, 2009 7:58 am > Subject: [Audacity-nyquist] INTRODUCTION TO DIGITAL FILTERS--Help with > individual signal ... > > http://ccrma.stanford.edu/~jos/filters/ > > > > INTRODUCTION TO DIGITAL FILTERS > > WITH AUDIO APPLICATIONS > > JULIUS O. SMITH III > > > > Center for Computer Research in Music and Acoustics (CCRMA) > > Department of Music, Stanford University, Stanford, California 94305 USA > > > > On Sat, 20 Jun 2009 10:13:10 -0400, "Roger Dannenberg" <[hidden email]> > > said: > > > Here's a high-level view and answer: > > > > > > What you are computing is called convolution. Convolution is a common > > > way to implement an FIR filter. In Nyquist, convolution by a short > > > signal like f(i) is implemented efficiently by CONVOLVE. You can > > > construct a signal like f(i) using SND-FROM-ARRAY, and you can construct > > > an array by allocating a new one using MAKE-ARRAY and filling in the > > > values with SETF, or you can call VECTOR to create and initialize an > > > array from arguments. Nyquist signals are indexed by non-negative time, > > > not by integers, so you will have to map your problem to the time domain > > > and think about boundary conditions -- you didn't say what is the origin > > > (initial index) of the input or output signals. You might have to pad > > > with zeros or remove some result samples to get the result you want. > > > When you construct a signal to represent f(i), give it the same sample > > > rate as s(j). > > > > > > -Roger > > > > > > [hidden email] wrote: > > > > I posted something similar on an Audacity forum but was referred to > > > > Appendix 1 on extending Nyquist with C programming. > > > > Since programming is a hobby and I don't know C or Lisp I thought a > > > > Nyquist-Lisp type solution might be easier but I'm not sure. > > > > Here is what I need. > > > > > > > > Say f(i) is a function of sampling index i and f(i) is fully defined > > > > on just 15 index values. > > > > > > > > Specifically, f(i) = 27/16(i^3 + 2i^2 + i) for i = -7 to 7. > > > > Now, there is some sound signal s(j) where j is it's sampling index. > > > > I wanted to form a new sound signal n(j) by summing the multiplied > > > > pairs f(i)s(j+i) for i = -7 to +7 for each possible j. > > > > > > > > f(-7)s(j-7) > > > > f(-6)s(j-6) > > > > f(-5)s(j-5) > > > > ... > > > > f(6)s(j+6) > > > > f(7)s(j+7) > > > > -------------- > > > > SUM the above to give a single value of n at some value of index j. > > > > -------------- > > > > Furthermore, I want to do this across all possible values of j for > > > > signal s to form the new signal n. > > > > Nyquist has some filter functions but none are cubic and I don't see a > > > > way to specify ones own filter function that would do what I want. > > > > How do you set this thing up? > > > > > > > > Thanks. ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
||||||||||||||||
|
paul beach-2
|
In reply to this post
by paul beach-2
I am trying fmosc. It returns audio but there is no infinite spectrum.
Just A-220 and A-110, below. Paul (scale 0.5 ( fmosc 57 (osc 45) ) ) -- paul beach [hidden email] ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
|
Roger Dannenberg
|
Are you expecting significant sidebands? If so, try increasing the index
of modulation, e.g. (fmosc 57 (mult 500 (osc 45))) -Roger paul beach wrote: > I am trying fmosc. It returns audio but there is no infinite spectrum. > Just A-220 and A-110, below. > > Paul > > (scale 0.5 > ( fmosc 57 (osc 45) ) > ) > ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
||||||||||||||||
|
paul beach-2
|
FM does not make sense for a modulation of say, more than 5%; at least
not, for electronic signal applications. Frequency deviation for commercial FM stations is in parts per thousand, say 200khz where the carrier is 100Mhz. Just comparing with a graphics program. M in the formula seems to be scaled, (if this is equivalent to FM below) (fmosc 57 (mult 500 (osc 45))) 500 == 2 M = maximum frequency deviation/modulating frequency. FM signal can be represented as: v = ac sin(wct + M sin wmt ) reference: http://cnyack.homestead.com/files/modulation/modfm.htm On Sun, 21 Jun 2009 21:16:23 -0400, "Roger Dannenberg" <[hidden email]> said: > Are you expecting significant sidebands? If so, try increasing the index > of modulation, e.g. (fmosc 57 (mult 500 (osc 45))) > > -Roger > > paul beach wrote: > > I am trying fmosc. It returns audio but there is no infinite spectrum. > > Just A-220 and A-110, below. > > > > Paul > > > > (scale 0.5 > > ( fmosc 57 (osc 45) ) > > ) > > > > ------------------------------------------------------------------------------ > Are you an open source citizen? Join us for the Open Source Bridge > conference! > Portland, OR, June 17-19. Two days of sessions, one day of unconference: > $250. > Need another reason to go? 24-hour hacker lounge. Register today! > http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org > _______________________________________________ > Audacity-nyquist mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/audacity-nyquist paul beach [hidden email] ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
||||||||||||||||
|
David R. Sky
|
In reply to this post
by Stevethefiddle
Hi,
For whatever it's worth, I've attached a plug I wrote several years ago for someone, fir101.ny. According to the guy, the output was "off" by one sample, whatever he meant by that. I had lots of trouble communicating with him and eventually gave up. David -- David R. Sky http://www.shellworld.net/~davidsky/ On Sun, 21 Jun 2009, Steve wrote: > On Sat, 2009-06-20 at 13:53 -0400, [hidden email] wrote: >> Hi Roger, >> >> First, thank you for the tips. >> The documentation in Nyquists functions for CONVOLVE is sparse. I'll >> need to research this one a bit more. >> >> I was going to approach things by sample indexes where I changed the >> sound s to an array using SND-FETCH or SND-FETCH-ARRAY and proceed >> with f(i). >> But I do see that your suggestion maybe easier. When using convolve >> with a signal-of-f(i) and s, since f(i) is short (15 samples) then >> does f(i) have to be repeat over and over (at s's sampling rate) in >> the creation of the signal-of-f(i) to make it the same length as the >> sound signal s? >> >> I was wondering about boundary conditions. I thought I would create >> the new signal from however many 15 sample "windows" I got from the >> original signal. This shortens the new signal. >> Your zero-padding suggestion does not shorten the new signal. Is >> zero-padding what's used in Nyquist's function to calculate RMS values >> of some signal and is this a "standard" approach found other places? >> >> >> Also, any suggestion on a good (easy to understand) Lisp tutorial. > > > > There are examples shown for each function in the XLisp manual: > http://www.audacity-forum.de/download/edgar/nyquist/nyquist-doc/xlisp/xlisp-ref/xlisp-ref-index.htm > > Steve > > > >> >> Have a good day. >> >> Mark. >> >> >> >> >> -----Original Message----- >> From: paul beach <[hidden email]> >> To: Discussion of developing Nyquist plug-ins for Audacity >> <[hidden email]> >> Sent: Sat, Jun 20, 2009 7:58 am >> Subject: [Audacity-nyquist] INTRODUCTION TO DIGITAL FILTERS--Help with >> individual signal ... >> >> http://ccrma.stanford.edu/~jos/filters/ >> >> >> >> INTRODUCTION TO DIGITAL FILTERS >> >> WITH AUDIO APPLICATIONS >> >> JULIUS O. SMITH III >> >> >> >> Center for Computer Research in Music and Acoustics (CCRMA) >> >> Department of Music, Stanford University, Stanford, California 94305 USA >> >> >> >> On Sat, 20 Jun 2009 10:13:10 -0400, "Roger Dannenberg" <[hidden email]> >> >> said: >> >>> Here's a high-level view and answer: >> >>> >> >>> What you are computing is called convolution. Convolution is a common >> >>> way to implement an FIR filter. In Nyquist, convolution by a short >> >>> signal like f(i) is implemented efficiently by CONVOLVE. You can >> >>> construct a signal like f(i) using SND-FROM-ARRAY, and you can construct >> >>> an array by allocating a new one using MAKE-ARRAY and filling in the >> >>> values with SETF, or you can call VECTOR to create and initialize an >> >>> array from arguments. Nyquist signals are indexed by non-negative time, >> >>> not by integers, so you will have to map your problem to the time domain >> >>> and think about boundary conditions -- you didn't say what is the origin >> >>> (initial index) of the input or output signals. You might have to pad >> >>> with zeros or remove some result samples to get the result you want. >> >>> When you construct a signal to represent f(i), give it the same sample >> >>> rate as s(j). >> >>> >> >>> -Roger >> >>> >> >>> [hidden email] wrote: >> >>>> I posted something similar on an Audacity forum but was referred to >> >>>> Appendix 1 on extending Nyquist with C programming. >> >>>> Since programming is a hobby and I don't know C or Lisp I thought a >> >>>> Nyquist-Lisp type solution might be easier but I'm not sure. >> >>>> Here is what I need. >> >>>> >> >>>> Say f(i) is a function of sampling index i and f(i) is fully defined >> >>>> on just 15 index values. >> >>>> >> >>>> Specifically, f(i) = 27/16(i^3 + 2i^2 + i) for i = -7 to 7. >> >>>> Now, there is some sound signal s(j) where j is it's sampling index. >> >>>> I wanted to form a new sound signal n(j) by summing the multiplied >> >>>> pairs f(i)s(j+i) for i = -7 to +7 for each possible j. >> >>>> >> >>>> f(-7)s(j-7) >> >>>> f(-6)s(j-6) >> >>>> f(-5)s(j-5) >> >>>> ... >> >>>> f(6)s(j+6) >> >>>> f(7)s(j+7) >> >>>> -------------- >> >>>> SUM the above to give a single value of n at some value of index j. >> >>>> -------------- >> >>>> Furthermore, I want to do this across all possible values of j for >> >>>> signal s to form the new signal n. >> >>>> Nyquist has some filter functions but none are cubic and I don't see a >> >>>> way to specify ones own filter function that would do what I want. >> >>>> How do you set this thing up? >> >>>> >> >>>> Thanks. > > > > ------------------------------------------------------------------------------ > Are you an open source citizen? Join us for the Open Source Bridge conference! > Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. > Need another reason to go? 24-hour hacker lounge. Register today! > http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org > _______________________________________________ > Audacity-nyquist mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/audacity-nyquist > > ;version 2 ;type process ;name "FIR filter 1.0.1..." ;action "Applying FIR filter..." ;info "by David R. Sky; thanks to GN for DSP help, Roger Dannenberg for nyquist pointers\nRepeat value repeats the taps list you have created, appends the second taps list, then inserts zeros between the tap values.\nIf normalization value > 0, normalization will be applied to result at that level.\nReleased under terms of GNU Public License" ;control values1 "Tap values" string "" "1 1 1 1 1 1 1 1 1 1 1" ;control zeros-1 "Units number of zeros between taps" int "" 0 0 1000 ;control zeros-1000 "Thousands of zeros between taps" int "" 0 0 10 ;control mirror "Mirror above taps list: 0=no 1=yes" int "" 0 0 1 ;control where "Mirror last tap: 0=no 1=yes" int "" 0 0 1 ;control repeat "Repeat above taps list" int "" 0 0 1000 ;control type "Type: 0=linear phase 1=moving average" int "" 0 0 1 ;control result "Result: 0=positive 1=complementary" int "" 0 0 1 ;control choice "Choice: 0=convolve 1=test convolution 2=display tap values" int "" 0 0 2 ;control values2 "Additional taps list" string "" "" ;control gain "Gain - percent" int "" 100 0 100 ;control norm "Above 0, normalization will be applied to result at this level" int "" 0 0 100 ; FIR filter 1.0.1 by David R. Sky; DSP help by GN, ; Nyquist pointers by Roger Dannenberg ; April 30, 2006 ; Released under terms of the GNU Public License ; http://www.opensource.org/licenses/gpl-license.php ; ; Version history - ; 1.0 April 17, 2006 ; 1.0.1 April 30 - ; re-arranged input fields and code; ; used mapcar to create 'true' kernel list ; [e.g. input taps 1 1 1 1 1 becomes 0.2 0.2 0.2 0.2 0.2 ; for 100% gain]; ; simplified function to convert list into array with zeros; ; created accurate prepended/appended zero padding for input signal ; and replaced sim with seq for this padding function ; determine duration of Audacity selection (setf dur (/ len *sound-srate*)) ; convert gain percent to floating value (setf gain (* 0.01 gain)) ; convert input string into a list ; input string is str, output list is assigned to symname ; thanks to Steven Jones (defun eval-string-to-list (symname str) (let ((form (strcat "(setq " symname " (list " str "))"))) (eval (read (make-string-input-stream form))))) ; convert values1 & values2 string inputs ; into list1 and list2 (eval-string-to-list "list1" values1) (eval-string-to-list "list2" values2) ; set reverse [mirrored] copy of list1 (setf mirror1 (reverse list1)) ; if where is 0, remove first value from mirror1 ; [if 'do not mirror last tap value' is chosen] (if (= where 0) (pop mirror1)) ; function to append mirrored copy of list1 to itself (defun add-mirror (list1 mirror1) (setf list1 (append list1 mirror1))) ; if mirror=1, extend list1 with mirror1 list (setf list1 (cond ((= mirror 0) list1) ; do not add mirror ((= mirror 1) ; add mirror (add-mirror list1 mirror1) ) ; end = mirror 1 ) ; end cond ) ; end setf list1 ; initialize m-list [master list] (setf m-list list1) ; repeat list1 repeat number of times (dotimes (i repeat ) (setf m-list (append m-list list1)) ) ; end dotimes i ; appending list2 to m-list (setf m-list (append m-list list2)) ; function to calculate weight of m-list ; [adds tap weights in list] ; returns weight flonum (DEFUN weigh (LST &optional (TOTAL 0.0)) (DOTIMES (I (LENGTH LST)) (SETF TOTAL (+ TOTAL (NTH I LST)))) total) ; calculate weight of m-list ; and apply gain (setf weight (* gain (weigh m-list))) ; function to convert individual tap weight to 'true' tap weight ; by dividing tap weight value by previously-calculated weight ; [called by mapcar function] (defun convert-tap-weight (value) (/ value weight)) (cond ((zerop weight) ; if total weight=0 generate error... (format nil "your tap values total a weight of zero. ~% ~% convolve function not tested or applied.")) (t ; ...otherwise convert m-list to master-list with 'true' values (setf master-list (mapcar 'convert-tap-weight m-list))) ) ; end cond ; calculate total zeros ; units-zeros plus thousands-zeros (setf zeros (+ zeros-1 (* zeros-1000 1000))) ; function to convert kernel master-list into an array, ; including zeros between tap weights. This array of values will become ; the response signal for the convolve function. (defun make-kernel-array (lst zeros) ; initialize some arguments: ; interval: number of samples from one tap weight to the next ; including zeros between tap weights (setf interval (1+ zeros)) ; len-array: length of array ; [total number of samples in kernel] (setf len-array (1+ (* interval (1- (length lst))))) ; initialize kernel array (setf kernel-array (make-array len-array)) ; stuff a zero into each array 'slot' (dotimes (i len-array) (setf (aref kernel-array i) 0)) ; sequentially stuff a tap weight from the kernel master list ; into each 'interval' slot (dotimes (j (length lst)) (setf (aref kernel-array (* j interval)) (nth j lst))) ) ; end defun make-kernel-array ; convert master list of tap values to kernel-array, ; with zeros between user-defined tap values (make-kernel-array master-list zeros) ; convert kernel-array to convolve response signal (setq response (snd-from-array 0 *sound-srate* kernel-array)) ; check that there are odd number of tap values ; for linear phase convolution. (if (and (= type 0) (evenp (length kernel-array))) (format nil "Error - tap values list has even number of tap values - ~a. ~% ~% Number of tap values must be odd for linear phase convolution. ~% ~% You can enter an even number of tap values with an odd number of zeros, vice versa, or add an odd number of tap values into the second tap values list." (length kernel-array)) (setf len-sil1 (if (= type 0) ; linear phase = [kernel-1]/2 zeros (truncate (* 0.5 (1- (length kernel-array)))) ; moving average = kernel-1 zeros (1- (length kernel-array)) ) ; end if ) ; end setf ) ; end if and ; number of appended zero samples ; [for the moment, they are same as prepended zeros] (setf len-sil2 len-sil1) ; convert prepended and appended zeros to sound (setf prepend (make-array len-sil1)) (dotimes (i len-sil1) (setf (aref prepend i) 0)) ; end dotimes i ; create the actual sound (setq prepend-silence (snd-from-array 0 *sound-srate* prepend)) (setf append (make-array len-sil2)) (dotimes (j len-sil2) (setf (aref append j) 0)) ; end dotimes j ; create the sound (setq append-silence (snd-from-array 0 *sound-srate* append)) ; function to add silence [zero padding] before and after Audacity selection (defun zero-pad (prepend-silence sound append-silence) (seq (cue prepend-silence) (cue sound) (cue append-silence) ) ; end seq ) ; end defun zero-pad ; function to convolve, using built-in Nyquist convolve function (defun convolve-s (prepend-silence signal append-silence response) (if (arrayp signal) (vector (convolve (zero-pad prepend-silence (aref signal 0) append-silence) response) (convolve (zero-pad prepend-silence (aref signal 1) append-silence) response) ) ; end vector (convolve (zero-pad prepend-silence signal append-silence) response) ) ; end if arrayp s ) ; end defun convolve-s ; function to normalize output of convolution result ; which is only applied when norm [normalization level] > 0 (defun normalize (norm signal) (cond ((> norm 0) (setf norm (* 0.01 norm)) (setf x (if (arrayp signal) (vector (max (peak (aref signal 0) ny:all) (peak (aref signal 1) ny:all) )) ; end max, vector (peak signal ny:all) ) ; end if arrayp ) ; end setf x (scale (/ norm x) signal) ) ; end norm>0 (t ; don't apply normalization, just generate convolution result (cue signal)) ) ; end cond ) ; end defun normalize ; Convolve, test convolution, or display tap values (cond ((= choice 0) ; apply convolution ; s1 is the signal ; to be added to the convolved result. ; if result=0 [positive] convolution, ; silence of duration 0 is added, ; otherwise inverted s is added to result ; to make complementary result. (setq s1 (if (= result 0) (s-rest 0.0) (mult -1.0 (zero-pad prepend-silence s append-silence)) ) ; end if ) ; end setq (normalize norm (sim (cue s1) (cue (convolve-s prepend-silence s append-silence response)) ) ; end sim ) ; end norm ) ; end choice=0 convolve ((= choice 1) ; apply convolve test to stereo Audacity selection ; end result: original l channel audio is in left channel ; convolve response is in right channel (if (arrayp s) ; if input signal is stereo (vector ; left channel, with zero padding at end (seq (cue (aref s 0)) (cue prepend-silence) (cue append-silence) ) ; end seq ; right channel (convolve (zero-pad prepend-silence (aref s 1) append-silence) response) ) ; end vector (format nil "Error - input signal is mono. ~% ~% For testing purposes, input signal must be in stereo, with identical signals in both channels. ~% ~% To create stereo input signal, select new stereo track from Project Menu in Audacity pre-1.3, otherwise from Track Menu in Audacity 1.3.x. Then create (load) a signal such as white noise or a tone from the Generate Menu and run the convolve test on that audio. ~% ~% after convolve test, original signal is in left channel, output convolved result is in right channel. ~% ~%") ) ; end if ) ; end choice=1 apply convolution test (t ; choice=2 display tap values (format nil "The list of tap values is: ~% ~a ~% " kernel-array) ) ; end choice=2 display tap values ) ; end cond #| Notes: 1. local variables? 2. to skip input signal samples [one every n samples]: try snd-fetch-array 3. to evaluate expression into a sound, check out snd-play |# ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
||||||||||||||||
|
Roger Dannenberg
|
In reply to this post
by paul beach-2
I thought we were talking about FM synthesis and computer music. Is
there a question I could help with? -Roger paul beach wrote: > FM does not make sense for a modulation of say, more than 5%; at least > not, for electronic signal applications. > > Frequency deviation for commercial FM stations is in parts per thousand, > say 200khz where the carrier is 100Mhz. > > Just comparing with a graphics program. > > M in the formula seems to be scaled, (if this is equivalent to FM below) > (fmosc 57 (mult 500 (osc 45))) > 500 == 2 > > M = maximum frequency deviation/modulating frequency. > > FM signal can be represented as: > > v = ac sin(wct + M sin wmt ) > > reference: > http://cnyack.homestead.com/files/modulation/modfm.htm > On Sun, 21 Jun 2009 21:16:23 -0400, "Roger Dannenberg" <[hidden email]> > said: > >> Are you expecting significant sidebands? If so, try increasing the index >> of modulation, e.g. (fmosc 57 (mult 500 (osc 45))) >> >> -Roger >> >> paul beach wrote: >> >>> I am trying fmosc. It returns audio but there is no infinite spectrum. >>> Just A-220 and A-110, below. >>> >>> Paul >>> >>> (scale 0.5 >>> ( fmosc 57 (osc 45) ) >>> ) >>> >>> >> ------------------------------------------------------------------------------ >> Are you an open source citizen? Join us for the Open Source Bridge >> conference! >> Portland, OR, June 17-19. Two days of sessions, one day of unconference: >> $250. >> Need another reason to go? 24-hour hacker lounge. Register today! >> http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org >> _______________________________________________ >> Audacity-nyquist mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/audacity-nyquist >> ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
||||||||||||||||
|
paul beach-2
|
Thanks Roger, your comments have helped me with this result.
The synth bassoon (double reed insturment) sounds like so: http://www.climatehoax.ca/music/bassoon.mp3 Feigenbaum first studied the discrete equation, f(x) = A * x * (1-x) on the domain 0<x<1, and found period doubling as "A" increases. The same principal is supposed to apply for other nonlinear equations, such as frequency modulation: An increase in M causes period doubling. F = sin(t + M * sin(t)) There is also another principle, a male voice cannot become a female voice, simply by increasing the speed. This would NOT be time invariant. Therefore each (bassoon)note has to have M readjusted. Basson can be copied and pasted into Nyquist prompt. Note that musical intruments have an (almost) regular overtone series in one dimension. Paul Beach ;bassoon (scale 3 (bandpass2 (s-exp (scale 2 (fmosc 50 (mult 450 (osc 50))) ) ) 222 22 ) ) -- paul beach [hidden email] ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
||||||||||||||||
|
Roger Dannenberg
|
paul beach wrote:
> Thanks Roger, your comments have helped me with this result. > > The synth bassoon (double reed insturment) sounds like so: > > http://www.climatehoax.ca/music/bassoon.mp3 > > Feigenbaum first studied the discrete equation, > f(x) = A * x * (1-x) on the domain 0<x<1, and found period doubling as > "A" increases. > > The same principal is supposed to apply for other nonlinear equations, > such as frequency modulation: An increase in M causes period doubling. > F = sin(t + M * sin(t)) > are the carrier frequency + or - multiples of the modulating frequency. > There is also another principle, a male voice cannot become a female > voice, simply by increasing the speed. This would NOT be time invariant. > > Therefore each (bassoon)note has to have M readjusted. > The main attraction of FM in synthesis is that a time-varying index of modulation (essentially M) can be used to generate spectral evolution with low cost and few parameters. But I agree that the spectrum in steady state will vary as a function of amplitude and pitch. ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
||||||||||||||||
|
paul beach-2
|
I did a graphic to compare increments of modulation. Period doubling
seems to be obvious, though not in the chaotic sense. Will look at Bessel functions, to see if any sense can be made of this. http://www.climatehoax.ca/music/fm_doubling.gif -- paul beach [hidden email] ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
||||||||||||||||
|
Roger Dannenberg
|
If anything, the frequency is doubling and period is halving, consistent
with a big increase in amplitude of the the second harmonic. Early papers by John Chowning have an analysis. -Roger paul beach wrote: > I did a graphic to compare increments of modulation. Period doubling > seems to be obvious, though not in the chaotic sense. Will look at > Bessel functions, to see if any sense can be made of this. > > http://www.climatehoax.ca/music/fm_doubling.gif > ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
||||||||||||||||
|
paul beach-2
|
In reply to this post
by Roger Dannenberg
Is repeated mult the only way to raise s to a power?
; ( power sound exponent ) won't work (sim (- 0.9) ; shift down even powers (scale 1.8 (mult ; sound^2 (fmosc 51 (mult 250 (osc 70))) (fmosc 51 (mult 250 (osc 70))) ) ) ) -- paul beach [hidden email] ------------------------------------------------------------------------------ _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
||||||||||||||||
|
Roger Dannenberg
|
You can use s-exp and s-log. -Roger
paul beach wrote: > Is repeated mult the only way to raise s to a power? > > ; ( power sound exponent ) won't work > (sim (- 0.9) ; shift down even powers > (scale 1.8 > (mult ; sound^2 > (fmosc 51 (mult 250 (osc 70))) > (fmosc 51 (mult 250 (osc 70))) > ) > ) > ) > ------------------------------------------------------------------------------ _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
||||||||||||||||
|
David R. Sky
|
In reply to this post
by paul beach-2
Hi Paul,
You might not have noticed yet that most if not all math functions which operate on sound have their own specific non-XLISP function. The simple ones substitute a word rather than a symbol: * mult / div + sum or sim etc. More complex functions have snd- prepended to the function such as ^ is snd-expt I think etc. David -- David R. Sky http://www.shellworld.net/~davidsky/ On Sat, 27 Jun 2009, paul beach wrote: > Is repeated mult the only way to raise s to a power? > > ; ( power sound exponent ) won't work > (sim (- 0.9) ; shift down even powers > (scale 1.8 > (mult ; sound^2 > (fmosc 51 (mult 250 (osc 70))) > (fmosc 51 (mult 250 (osc 70))) > ) > ) > ) > ------------------------------------------------------------------------------ _______________________________________________ Audacity-nyquist mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/audacity-nyquist |
||||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |