       Determining Frequency Distributon and Applying Rules

• To: mathgroup at smc.vnet.net
• Subject: [mg102126] Determining Frequency Distributon and Applying Rules
• From: BenT <brtubb at pdmusic.org>
• Date: Thu, 30 Jul 2009 05:31:44 -0400 (EDT)

```I'm working with algorithmic music methods. For creating melodies for
any scale size (i.e. 2-12) using the number base conversion ability if
the RealDigits' function is very convenient. Irrational numbers of
virtually infinite length also make excellent arbitrarily sized
lengths for such melodies. Using RealDigits to effectively "map" the
digits of the numbers into, eventually, scale notes (diatonic or not)
is even more convenient.

If given a list of integers such as

x1 = RealDigits[N[Sqrt, 32], 7][]

where the interger values which can be of arbirtrary length (in this
case 32), based on an irrational number (in this case Sqrt), how
can their relative frequency distribution be determined for each
"weighted" integer which are then initially re-mapped to 0 thru 6
[for any arbitrary seven note scale] such that a rule can then be
applied to map those in descending order (greater frequency thru
lesser, including "ties") to notes (representing the diatonic circle
of fifths) with the additional mapping using this rule:

rule=(0,4,1,5,2,6,3)

which, in C major, corresponds to the notes C,G,D,A,E,B,F.

For example, if given the (base 7) list x={3,5,2,6,2,5} then their
weighted frequency distribution order would be 2,5,3,6 because ties
are listed and mapped in numeric order. Thus their values would be
thus remapped according to "rule" to

2->0, 5->4, 3->2, 6->5

by y=y /. rule

and therefore the final list produced would be

y={2,4,0,5,0,4}

Once that is achieved then the actual "absolute" pitch values for a
given scale can be used for further use in as a SoundNote pitch
paramenter, e.g. mapping to C major can be done with the rule:

cmajrule={0->0,1->2,2->4,3->5,4->7,5->9,6->11}

which I could then use (for example) for

Sound[SoundNote[#,4,49] & /@y,{0,4}

Although for added "tonal emphasis" I might/would change "y" first to
a result that includes the tonic before and after the note list.

y = Prepend[y, 0]
y = Append[y, 0]

Any help would be appeciated.

Ben Tubb
brtubb at pdmusic.org

```

• Prev by Date: Problems with NDSolve and SymplecticPartitionedRungeKutta method
• Next by Date: Re: Re: ReplacePart except first element?
• Previous by thread: Problems with NDSolve and SymplecticPartitionedRungeKutta method
• Next by thread: Re: The audience for Mathematica