Created
March 20, 2016 20:06
-
-
Save peschwa/638df29b3f394cdf3cdf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[psch@mnpc Audio-PortMIDI]$ git diff | |
diff --git a/examples/amen b/examples/amen | |
index 6dd7f30..37d756b 100755 | |
--- a/examples/amen | |
+++ b/examples/amen | |
@@ -52,7 +52,7 @@ class DrumTab::Actions { | |
} | |
} | |
-sub MAIN(Int :$bpm = 120, Int :$channel = 9, Int :$device = 3) { | |
+sub MAIN(Int :$bpm = 165, Int :$channel = 9, Int :$device = 3) { | |
my $event-type = NoteOn; | |
@@ -67,7 +67,9 @@ sub MAIN(Int :$bpm = 120, Int :$channel = 9, Int :$device = 3) { | |
my $stream = $pm.open-output($device, 32); | |
- my $note = 0; | |
+ my $note = 0; | |
+ my $jump-note = 0; | |
+ my $jump-dir = 1; | |
react { | |
whenever Supply.interval(60/($bpm * 4)) { | |
@@ -81,10 +83,18 @@ sub MAIN(Int :$bpm = 120, Int :$channel = 9, Int :$device = 3) { | |
$stream.write(@notes); | |
if $note == 63 { | |
- $note = 0; | |
+ $note = $jump-note = 0; | |
} | |
else { | |
$note++; | |
+ | |
+ $jump-dir = rand < .5 ?? -2 !! 2; | |
+ $jump-note = 4.rand.Int * $jump-dir; | |
+ $jump-note div= 2; | |
+ $jump-note *= 2; | |
+ $jump-note %= 64; | |
+ | |
+ $note = rand > .2 ?? $note !! $jump-note; | |
} | |
} | |
} | |
diff --git a/lib/Audio/PortMIDI.pm b/lib/Audio/PortMIDI.pm | |
index 61f4d31..52b8a23 100644 | |
--- a/lib/Audio/PortMIDI.pm | |
+++ b/lib/Audio/PortMIDI.pm | |
@@ -4,7 +4,7 @@ use NativeCall; | |
class Audio::PortMIDI { | |
- constant LIB = ('portmidi',v0); | |
+ constant LIB = 'portmidi'; | |
enum Error ( | |
NoError => 0, | |
[psch@mnpc Audio-PortMIDI]$ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment