[Date Index]
[Thread Index]
[Author Index]
Re: Error using Manpulate that is NOT obvious (to me)
*To*: mathgroup at smc.vnet.net
*Subject*: [mg96770] Re: Error using Manpulate that is NOT obvious (to me)
*From*: "Nasser Abbasi" <nma at 12000.org>
*Date*: Tue, 24 Feb 2009 05:47:11 -0500 (EST)
*References*: <gntsab$rh6$1@smc.vnet.net>
*Reply-to*: "Nasser Abbasi" <nma at 12000.org>
<brtubb at pdmusic.org> wrote in message news:gntsab$rh6$1 at smc.vnet.net...
> Using Mathematica 6.0.2, I can't get this relatively straight forward code
> to
> work, Can anyone explain what's wrong and how to fix it. It's
> essentially intended to be musician utility for using the SoundNote
> function which I hope to further elaborate by also converting any
> (MIDI note range frequency) into the appropriate MIDI note number and
> pitch bend values assumming a fine tuning RPN range of +/- 1 semitone,
> allowing 100 cents "sensitivity" to be defined.
>
> Manipulate[
> DynamicModule[{f, m, s, sd, pt, p, o},
> f = N[(440/64) 2^((m + 3)/12)];
> sd = {"C", "C#", "D", "D#", "E", "F",
> "F#", "G", "G#", "A", "A#", "B"};
> s = m - 60;
> pt = Mod[m, 12];
> p = sd[[pt + 1]];
> o = Integer[m/12] - 1;
> Print[
> "MIDI Note Number (0-127)", m,
> " equals ", f, " Hertz (8-12600)",
> ", and its SoundNote number (-60 to 67) is ", s,
> ", which has the Pitch name of (C to B) ", p,
> " in Octave (-1 to 9) ", o, "."
> ]
> ],
> {m, 0, 127, 1},
> SaveDefinitions -> True
> ]
>
> Benjamin Tubb
> using Mathematica 6.0.2
> and still occasionally v3.0.1 <g>
>
I do not use DynamicModule, but like to put all the functions used by
Manipulate in its Initialization section.
Here is my version of your code. May be you need to work on the formating
part little more, but this seems to work.
Manipulate[process[m], {m, 0, 127, 1}, Initialization :>
{process[m_] := Module[{f, s, sd, pt, p, o},
f = N[(440/64)*2^((m + 3)/12)]; sd = {"C", "C#", "D", "D#", "E",
"F", "F#", "G", "G#", "A", "A#", "B"}; s = m - 60;
pt = Mod[m, 12]; p = sd[[pt + 1]]; o = Integer[m/12] - 1;
Text[StringJoin["MIDI Note Number (0-127) ", ToString[m],
", equals ", ToString[f],
", Hertz (8-12600), and its SoundNote number (-60 to 67) is ",
ToString[s], ", which has the Pitch name of (C to B) ",
ToString[p], " in Octave (-1 to 9) ", ToString[o], "."]]]}]
--Nasser
Prev by Date:
**newbie: programmatic sequence of plots?**
Next by Date:
**Re: DiscretePlot**
Previous by thread:
**Re: Error using Manpulate that is NOT obvious (to me)**
Next by thread:
**Re: Error using Manpulate that is NOT obvious (to me)**
| |