Re: Defining a Play[] function for Drawbar Organ Emulation
- To: mathgroup at smc.vnet.net
- Subject: [mg87162] Re: Defining a Play[] function for Drawbar Organ Emulation
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Wed, 2 Apr 2008 05:58:34 -0500 (EST)
- Organization: The Open University, Milton Keynes, UK
- References: <fsvebo$sot$1@smc.vnet.net>
brtubb at pdmusic.org wrote: > Although I have no problem PLOTing such a function as this, I cannot > get it to work with the Play[] function. Can anyone help? This is > based on the 11-drawbar organ stops used on some hammond organs (such > as the X-66 model) which I am trying to emulate for additive synthesis > output in a future Demonstration Project (I am using Mathematica 6). > > ElevenDrawbars[f_, d_String] := > Module[{d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, h10, d11, h11, z}, > d = StringTake[d, {1}] <> StringTake[d, {2}] <> StringTake[d, {4}] <snip> > In[30]:= ElevenDrawbars[440, "00 8845 041 00"] > > During evaluation of In[30]:= Set::setraw: Cannot assign to raw \ > object 00 8845 041 00. >> <snip> What Mathematica is telling you is that one cannot change the value of a string, "AA" = "BB" is illegal (as well as meaningless). The string parameter d, therefore, cannot be modified by the first *Set* statement of your code: use another name for it, like dd in the following example. ElevenDrawbars[f_, d_String] := Module[{dd, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, h10, d11, h11, z}, dd = StringTake[d, {1}] <> StringTake[d, {2}] <> StringTake[d, {4}] <> StringTake[d, {5}] <> StringTake[d, {6}] <> StringTake[d, {7}] <> StringTake[d, {9}] <> StringTake[d, {10}] <> StringTake[d, {11}] <> StringTake[d, {13}] <> StringTake[d, {14}]; d1 = ToExpression[StringTake[dd, {1}]]; d2 = ToExpression[StringTake[dd, {2}]]; d3 = ToExpression[StringTake[dd, {3}]]; d4 = ToExpression[StringTake[dd, {4}]]; d5 = ToExpression[StringTake[dd, {5}]]; d6 = ToExpression[StringTake[dd, {6}]]; d7 = ToExpression[StringTake[dd, {7}]]; d8 = ToExpression[StringTake[dd, {8}]]; d9 = ToExpression[StringTake[dd, {9}]]; d10 = ToExpression[StringTake[dd, {10}]]; h10 = d11/2; d11 = ToExpression[StringTake[dd, {11}]]; h11 = d11/2; z = N[2 Pi]; Play[d1 Sin[1/2 f x z] + d2 Sin[3/2 f x z] + d3 Sin[f x z] + d4 Sin[2 f x z] + d5 Sin[3 f x z] + d6 Sin[4 f x z] + d7 Sin[5 f x z] + d8 Sin[6 f x z] + d9 Sin[8 f x z] + d10 Sin[7 f x z] + h10 Sin[9 f x z] + d11 Sin[10 f x z] + h11 Sin[12 f x z], {x, 0, z}, SampleDepth -> 16, SampleRate -> 44100]] ElevenDrawbars[440, "00 8845 041 00"] [... sound player deleted ...] HTH, -- Jean-Marc