Euclidean Rhythm Music Sequencer Using Actors

Euclidean Rhythm Music Sequencer Using Actors

Euclidean Rhythm Music Sequencer Using Actors by Dan Prince CPS592 Spring 2016 Outline ● Introduction ● Demonstration ● Euclidean Rhythms using Generators ● Concurrency using Actors ● Conclusion Introduction - Musical Terminology ● Sequencer: a device used to record and transmit musical notes for the purpose of representing a performance electronically. ● Sequence: a series of notes stored in a sequencer that represents a complete musical phrase. ● Step: the smallest discrete musical unit represented by the sequencer. ● Part: the sequence that corresponds to a single instrument. In this application, there are six parts. Introduction Apple Garageband A vast range of music production software has become available recently due to the increasing power of personal computers and increasing popularity of audio production among Ableton Live hobbyists and professionals alike. There is a want on behalf of musicians and producers for software to become endlessly more flexible and creative. Introduction No single audio production application is sufficient. This diversity of applications is great for inspiring new sounds and new workflows! In this application, I aim to create ● GUI using Python TK a simple and flexible interactive ● Six different drum parts ● Mute option for each part drum sequencer that can be used ● Live modification of parameters and for live performance and sequences improvisation. ● Sequences based on the Euclidean rhythm algorithm Demonstration Euclidean Rhythms Based on Euclid’s algorithm for Generating a rhythm: computing the greatest common k=5, n=13 divisor of two given integers. [1][1][1][1][1] [0][0][0][0][0][0][0][0] “[Euclid’s algorithm] is very simple. → [10] [10] [10] [10] [10] [0] [0] [0] Repeatedly replace the larger of the two numbers by their difference until → [100] [100] [100] [10] [10] both are equal.” where “1” indicates an active step, and “0” indicates an inactive step G.T. Toussaint “The Euclidean algorithm generates traditional musical rhythms.” In Proceedings of BRIDGES: Mathematical Connections in Art, Music and Science, pages 47–56, 2005. Euclidean Rhythms from itertools import cycle # Where n is the length of the sequence's period and k is the number using Generators # of active steps in the sequence def euclidean_rhythm(k,n): # If either parameter is zero, return a generator that # always returns zero if k == 0 or n == 0: return cycle([0]) Higher order functions can be # Keep track of the number of inactive and active steps # remaining to distribute used to simplify the programming inactive, active = [n-k], [k] # Compute the Euclidean algorithm recursively for the Euclidean rhythm def euclid(m,k,steps): # If all active steps have been distributed, or if there are algorithm, and generators # no inactive steps to distribute, return the final result with # all of the remaining inactive steps being evenly distributed. if k == 0 or inactive[0] == 0: represent the resulting sequence return map(lambda x: x +[0]*(inactive[0]/active[0]), steps) else: # Distribute an inactive step to each list inactive[0] = inactive[0]-k return euclid(k, m % k, map(lambda x: x+[0], steps[:k]) + steps[k:]) Notice: Python allows for, but # Return a generator that infinitely repeats a cycle of the # sequence resulting from the Euclidean algorithm does not promote, a functional return cycle(reduce(lambda x,y: x+y, euclid(max(active[0],inactive[0]), min(active[0],inactive[0]), programming style [[1]]*k))) Concurrency using Actors Three Actors are used: TimingActor: Count musical divisions of time NoteActor: Generate rhythms and send notes GuiActor: Display status and enable interaction Concurrency using Actors class TimingActor(pykka.ThreadingActor): The definition for the simplest def __init__(self): super(TimingActor, self).__init__(use_daemon_thread=True) Actor is shown here: self.playing = False def tick(self, count): if self.playing: self.target.tell({'type': 'tick'}) The Pykka library allows for an Timer(self.period, self.tick, args=[count+1]).start() def on_receive(self, msg): object oriented approach to if msg['type'] == 'config': # Set the sixteenth note period for this Actor creating Actors self.period = 1.0/msg['bpm']*60.0 / 4.0 # Get NoteActor URN self.target = ActorRegistry.get_by_urn(msg['target']) self.tick(0) Useful, but not as easy as in elif msg['type'] == 'play': self.playing = True; self.tick(0) elif msg['type'] == 'stop': self.playing = False Erlang/Elixir Conclusion ● A working drum sequencer based on the Euclidean rhythm algorithm has been developed ● The Actor model of concurrency has been shown to be well suited for problems involving interactive musical timing ● Python’s capacity for functional programming has been explored Thanks! Questions?.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    13 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us