MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Determining Frequency Distributon and Applying Rules

  • To: mathgroup at
  • Subject: [mg102126] Determining Frequency Distributon and Applying Rules
  • From: BenT <brtubb at>
  • 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[2], 32], 7][[1]]

where the interger values which can be of arbirtrary length (in this
case 32), based on an irrational number (in this case Sqrt[2]), 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:


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


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:


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

  • 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