Tag Archives: Markov

Cranking out Engines

It's almost mid-March already.  I don't like that fact the the samples haven't improved appreciably in a while.  As I noted earlier, it's mostly due to the fact that I've been upgrading internals rather than working on sound.  Still, it's time to step on it.

Over the past few weeks, I've been working like mad to re-code all the old engines in c++, taking advantage of the massive optimizations possible therein.  So far, the following engines are now at least partially-functional as part of the new c++ library:

  • Artificial Neural Network Engine (was actually never implemented in AHK and has yet to be used in a plugin)
  • Contour Grammar
  • Evolutionary Engine
  • Fraccut
  • Markov Engine
  • Multi-State Engine

ALL of the new implementations are better than their predecessors, both in terms of efficiency and ease-of-use.  Certain complex engines such as the Markov engine may see speed increases of over a thousand fold thanks to redesigning.

By the end of the month, these myriad engines should be coming together to form some really powerful new plugins.  All it takes is code.

Generalized Markov Engine

Picking XIAS up again, I'm now working on developing a flexible and lightweight Markov engine to give the XIAS library stochastic abilities.

Potential features for the Markov engine:

  • Hierarchical storing of event probabilities for fast access time
    • Will require hefty upgrade of Object System data structure
    • Similar to GDS
    • Improve access times for complex data structures
  • Overlapping of orders
    • Markov chains of different orders can have different "weights" that contribute to the overall probability of an event occurring
    • Gives the user the ability to control how deeply the engine considers the past states when calculating probabilities
  • Arbitrary event-handling
    • Events don't have to take any particular structure - in fact, events could even have other data encoded into them to further enhance the predictive capabilities of the engine when outside variables may be influencing the future

Unfortunately, as mentioned in the notes above, making the engine efficient is going to require an overhaul of the Object System data structure created recently. It will require the ability to store substructures as single elements of larger structures to speed up access times (which I'm quite certain would get out of hand quickly for large systems in which many events contribute to the weightings). This ability will bring OS closer to the functionality of GDS. The main difference, however, will lie in the syntax. I still intend for OS to have easy, OOP-like syntax (Parent.sublevel1.sublevel2 ... variable = blah). All previous OS code will need to function after the rewrite.

When the Markov engine is finished, XIAS will boast a truly wide range of algorithms. I can only imagine the hybrid possibilities.

Here's what I'm thinking: a genetic algorithm that dynamically evolves Markov probability spaces that are based on an underlying grammatical system analysis, wherein the words of the grammar come from a fractal cutting engine whose parameters are fed by an L-system. Talk about one hybrid algorithm to rule them all!

Computer Models of Musical Creativity (4)

Computer Models of Musical Creativity (David Cope)
Chapter 4: Recombinance

  • Western tonal music generally follows simple principles that drive melody, harmony, voice leading, and hierarchical form
  • One can create music by programming such principles into a computer
  • Such an approach often creates stale music
  • Recombinance is a method of using existing music and recombining it logically to create new music
  • Cope uses destination pitches and beat-size groupings to split chorales into smaller groups called lexicons that can be recombined using the pitch and beat data
  • Such syntactic networking actually preserves a great deal of the music's integrity while generating new output
  • To further extend the abilities of recombinance, Cope had his program analyze the source piece's "distance to cadence, position of groupings in relation to meter, and other context-sensitive features"
  • Artists often use musical signatures, patterns of notes that recur in many works of a composer
  • Recombinance can be described in terms of Markov chains
  • Recombinance can work both vertically and horizontally
  • Generation of music must start with an abstract hierarchy and move towards specifics (this is exactly what I foresaw and intended when I made the structure module the foundation upon which mGen works! Cope agrees!)
  • Rule acquisition from music models the musical training of humans
  • Machine renditions of music are often crude and dead...successful algorithmic composition requires dynamics
  • An improviser basically has a repertory and an idea of how he or she wants an improvised idea to flow into the next
  • "Recombinance, or rules acquisition, provides more logical and successful approaches to composing in tonal music styles"
  • "Every work of music, I feel, contains a set of instructions for creating different but highly related replications of itself"
  • "The secret of successful creativity lies not in the invention of new alphabet letters or musical pitches, but in the elegance of the combination and recombination of existing letters and pitches"
  • "In recombination, rules are not necessary, since the destination notes provide all of the requisite information"
  • "While recombinance of this type ensures beat-to-beat logic in new compositions, it does not guarantee the same logic at higher levels"
  • "The initial and final groupings of a phrase are most pivotal"
  • "Experiments in Musical Intelligence protects signatures from being fragmented into smaller groupings, thus ensuring that these signatures will survive the recombination process"
  • "A Markovian description of recombinant processes does not allow for the broader control of larger-scale structure"
  • "In music, what happens in measure 5 may directly influence what happens in measure 55, without necessarily affecting any of the intervening measures"
  • "The top-down approach is necessary because choosing new beat-to-beat groupings must be informed by hierarchy, and not the reverse. No new grouping of a work-in-progress can be selected until its implications for the entire structure of the work are determined"
  • "Acquired rules are often more accurate since, by default, they originate from the music itself and not from generalizations about the music"
  • "Having a program first derive rules and then apply these rules during composition, though a simple notion, is critically important to the basic thrust of my modeling creativity"
  • "I continue to maintain that computer-composed music in any style is as real as human-composed music in any style"
  • "I see no reason why computer-created music cannot move us to tears, find roots in our cultures, and reveal or obscure its internal implications as much as any music composed in more traditional ways"
  • "Improvisation consists of either generating music associatively to maintain continuity, or interruptively striking out in apparently new directions"
  • "Improvisers associate rhythmic patterns, melodic contours, and harmony"
  • "Improvisation tends to function as a series of gestures that themselves have a sense of beat and that, when performed one after another, make musical, rhythmic, and metric sense"

Computer Models of Musical Creativity (3)

Computer Models of Musical Creativity (David Cope)
Chapter 3: Current Models of Musical Creativity

  • Although randomness often competes with creativity in terms of surprise, it is no substitute for a creative process
  • Most random processes are simply too complex to predict
  • Randomness arises from a lack of predictability using logic, not a lack of determinism
  • Good creativity simply requires good algorithms
  • Some models of creativity include cellular automata, mathematical models, fuzzy logic, neural networks, and Markov chains
  • Using Markov chains, one can analyze a piece of music and produce new music in roughly the same style
  • Genetic algorithms operate on the principle of natural selection
  • Genetic algorithms and cellular automata can both generate very complex output
  • In rule-based programs, creativity really belongs to the programmer, not the program
  • Neural networks use "hidden unit" networks to simulate the output of a given situation based on a sample input and output
  • Neural networks simulate the workings of the human brain
  • Mathematical formulas can be used to produce quasi randomness
  • "Randomness is not an engaging mystery, but a simple reflection of ignorance"
  • "Randomness refers to behavior that is either too complex, too patternless, or too irrelevant to make prediction possible"
  • "For those believing that using algorithms to create music somehow removes imagination, inspiration, and intuition from the composing process, know that defining a good algorithm requires as much imagination, inspiration, and intuition as does composing a good melody or harmony"
  • "Neither good algorithms nor good musical ideas grow on trees"
  • "Integrating association-based procedures with data-driven processes increases the creative potential of this approach to music composition"
  • "GAs typically involve DNA-like inheritance of characteristics as well as crossover and mutation techniques to develop new traits"
  • "Neural networks then cycle through a series of forward or back propagations that compare output with input and alter hidden unit values, until the output values match or approximate the relationships of the input and output data upon which they were trained"
  • "Sandwiched between these nodes are variable numbers of layers of hidden units, as well as variable numbers of connections between these inputs, outputs, and hidden units, making the training process extremely complex"
  • "We should not overestimate the abilities of neural networks or let comtivity mask a lack of true creativity"
  • "Mathematical origins for algorithmic music, while occasionally producing interesting results, in no way indicate the presence of creativity"
  • "Computer programs must be sufficiently independent of their programmers and users in order to qualify as truly creative. Most apparently creative algorithmic composing programs either produce enormous output from which users make preferential choices or invoke so many programmer-defined rules that the software only proves the creativity of the programmer"

Bland Statistics

Unfortunately, the analysis tool used to create a permutation of Super Mario has ultimately led me to a dead-end. While such analytic methods might help for basic applications such as chord progressions, they clearly don't work as well when applied to individual notes, since duration, velocity, and padding must also be taken into account.

If I had the time to develop a more comprehensive analysis tool that used more than just a first-order transitional Markov matrix, I might extract better results from this analytic method. I feel, however, that this would simply take too long. Such intense analysis would merit an entire thesis all of its own.

Super Mario Statistics

Today I created a program to perform a first-order Markov analysis on midi files and use the collected data to create a new, random 'permutation' of the file while maintaining the same approximate first-order Markov statistical profile.  I used the super mario brothers game theme song as my source midi file and the result was surprisingly interesting.  Considering the simplicity of the statistics collected, I think the results demonstrate the feasability of a stylistic permutation tool as discussed in a previous post.

Ideas on the Quantification of Style

Today I worked on developing a structural outline for a system capable of analyzing and quantifying the essence of musical "style." The analysis will consist primarily of Markov chains with criteria automatically developed and analyzed by the program in the style of a nodal or neural network. In this way, the program will learn autonomously what criteria best 'define' a style and thus learn to reproduce new music in this style.

Markov Drumming Ideas

I need to create a list of statistical attributes that can be analyzed and linked to form a statistical Markov profile for drum styles. I also need to establish how attributes will be stored. Here are some ideas:

Format for statistical attribute: Node-(Trigger:Boolean Operator:Trigger...)=[Correlation],[Strength]

Examples
Snare-(Beat5:AND:CHatLast1)=26.73,2
Snare-(Beat5:AND:!CHatLast1:AND:ChatLast2)=53.9,4

The above attributes specify a few things. First, there is a 26.73% chance that a snare hit will directly follow a closed hi-hat hit on beat 5 (meaning the hi-hat hit falls on beat 4 and the snare hit falls on beat 5). Second, there is a 53.9% chance that a snare hit will follow a closed hi-hat hit by two beats on beat 5 provided that it does not directly follow a closed hi-hat hit (meaning the hi-hat hit falls on beat 3, beat 4 must not be filled by a hi-hat hit, and the snare hit falls on beat 5).

I think that these kinds of logical combinations will allow a thorough analysis of percussive styles.

Absolute Beat
The most basic trigger, this fires on a specific beat number.

Modulus Beat
Very similar to the absolute beat trigger, this trigger fires for each beat number computed modulus a certain divisor. In other words, it may fire every fourth beat, or every other beat, etc.

More on triggers later.

Markov Drumming Ideas

The Problem: Given a Markov analysis module, particularly for percussion, analyzing pieces of different styles (or even a single piece with slight variations in style) and averaging them into a primary statistics file would cause the file to become a "soup" of conflicting styles. This mushy average would turn into a rather nasty output. It's like taking vibrant blue and green, both very nice colors when taken separately, and combining them to get a nasty brown.

Possible Solution: When analyzing pieces, create statistical profiles of each segment (on an individual measure, or maybe a 4-measure basis) and compare the divergence of the statistics. If the divergence measure surpasses a certain threshold (which the user may set), then the segments are treated as separate styles that use separate statistical profiles. If they don't diverge by much, then the statistics can safely be averaged and saved to the main statistical profile for that style. It's like averaging all the shades of red and all the shades of green separately, so as to avoid mixing to get brown. Furthermore, an overarching statistical profile for style transitions could be made so that the drummer knows how often Style A moves to Style B and when, based on the segmented analysis of each piece. In this way, the analysis could conceivable decipher and reproduce an entire sequence of Intro, Verse, Chorus, Verse, etc. without actually understanding what each part means, just knowing that the statistical profiles for each diverge and transition into each other in certain parts of the composition.