Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add module to convert midi values to pitch class and octave informati…

…on separately
  • Loading branch information...
commit 6ae6e1f45b8b65b8b4c6da0b475df5bbd1384d47 1 parent a5d6e9c
@mwittels mwittels authored
Showing with 24 additions and 0 deletions.
  1. +24 −0 modules/MIDI_to_pitch_class.py
View
24 modules/MIDI_to_pitch_class.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+# Owner: <your name> (<your email>)
+# Summary: takes a list of MIDI chords and outputs the list of pitch class set classes,
+# and their corresponding octaves
+
+from module import *
+
+class MIDIToPitchClass(Module):
+
+ def generate_output(self):
+ #obtain list of MIDI values as chords (i.e., lists)
+ MIDIChords = self.get_input("in0")
+ #obtain "base" note which will be labeled 0 in every octave in MIDI form
+ MIDIBase = self.get_input("in1")
+
+ pitch_classes = []
+ octaves = []
+ for chord in MIDIChords:
+ pitch_classes.append([(note-MIDIBase)%12 for note in chord])
+ octave.append([int(round(note-MIDIBase/12)) for note in chord])
+
+ #Once processing is complete, set the output(s) of the module by calling self.set_output(<output>, <output port>)
+ self.set_output(pitch_classes, "out0")
+ self.set_output(octaves, "out1")
Please sign in to comment.
Something went wrong with that request. Please try again.