xi-midi 0.1.0 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0054fce720de93807aaae4f8a831e8f6630ff2d
4
- data.tar.gz: 86b5f9503158cb98d54055315c899014055097bf
3
+ metadata.gz: e744c9b11148667886a22d33a97854d6965dfd82
4
+ data.tar.gz: 98ae2827a7f5ae07629f254a706aa7fc7cf72b0d
5
5
  SHA512:
6
- metadata.gz: 6c5e72413f734805515921452edbd9ddaad362a4f086b7191ccba87575858e47c092a4fb52ed09149fc5e545edd42a29afc7477e77d0751a428411bd76ae813b
7
- data.tar.gz: 46eee9088db90c41ab27e075b924a2bd89668cf2d1fee12152505384dbda6ac4e23fc3e63224845dcb231f248066af38cf37fa5d5e8321acd00a211be537102e
6
+ metadata.gz: 7ec2b45575d310e0cd2d9d748155c885bb410ab3196a762f8227bf6694967faa05e80c462a84b546b329384d92c6a54a0df8289df3097bfb1e6537663e9b2509
7
+ data.tar.gz: ec55b9d6864031e17007b7d908b82958d728d87f3f4c43b980587d22ba8d55bd6149c33e5b05d8622007464cff0b8d74ee184f0986638f1f2bdb48f2b40ba158
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in xi-midi.gemspec
4
4
  gemspec
5
-
6
- gem 'rawmidi', git: 'https://github.com/munshkr/rawmidi-ruby'
@@ -5,4 +5,6 @@ module Xi
5
5
  module MIDI
6
6
  # Your code goes here...
7
7
  end
8
+
9
+ Midi = MIDI
8
10
  end
@@ -73,13 +73,8 @@ module Xi::MIDI
73
73
  def send_bytes(device, *bytes)
74
74
  return unless open?(device)
75
75
 
76
- logger.debug([:send_bytes, device, bytes].join(', '))
76
+ debug(:send_bytes, device, bytes)
77
77
  @mutex.synchronize { @outputs[device].write(bytes) }
78
78
  end
79
-
80
- def logger
81
- # FIXME this should be configurable
82
- @logger ||= Logger.new("/tmp/xi.log")
83
- end
84
79
  end
85
80
  end
@@ -2,23 +2,22 @@ require 'xi/stream'
2
2
  require 'xi/midi/proxy'
3
3
 
4
4
  module Xi::MIDI
5
- class Stream < ::Stream
5
+ class Stream < Xi::Stream
6
6
  attr_accessor :device, :channel
7
7
 
8
- def initialize(clock, device: 0, channel: 0)
9
- super(clock)
8
+ def initialize(name, clock, device: 0, channel: 0)
9
+ super
10
10
 
11
11
  @device = device
12
12
  @channel = channel
13
13
  @playing_notes = {}
14
14
 
15
- midi.open(device)
15
+ midi.open(device) unless midi.open?(device)
16
16
  at_exit { kill_playing_notes }
17
17
  end
18
18
 
19
19
  def set(**params)
20
- params[:gate] = :midinote
21
- super(params)
20
+ super(gate: :midinote, **params)
22
21
  end
23
22
 
24
23
  def stop
@@ -37,38 +36,47 @@ module Xi::MIDI
37
36
  end
38
37
  end
39
38
 
40
- def do_gate_on_change(so_ids)
39
+ def do_gate_on_change(changes)
40
+ debug "Gate on change: #{changes}"
41
+
41
42
  channel = Array(@state[:channel] || 0)
42
43
  midinote = Array(@state[:midinote] || 60)
43
44
  velocity = Array(@state[:velocity] || 127)
44
45
 
45
- so_ids.each.with_index do |so_id, i|
46
- channel_i = channel[i % channel.size]
47
- midinote_i = midinote[i % midinote.size]
48
- velocity_i = velocity[i % velocity.size]
46
+ changes.each do |change|
47
+ change.fetch(:so_ids).each.with_index do |so_id, i|
48
+ channel_i = channel[i % channel.size]
49
+ midinote_i = midinote[i % midinote.size]
50
+ velocity_i = velocity[i % velocity.size]
49
51
 
50
- logger.info "MIDI Note on: #{[channel_i, midinote_i, velocity_i]}"
51
- midi.note_on(@device, channel_i, midinote_i, velocity_i)
52
+ debug "MIDI Note on: #{[channel_i, midinote_i, velocity_i]}"
53
+ midi.note_on(@device, channel_i, midinote_i, velocity_i)
52
54
 
53
- @playing_notes[so_id] = {channel: channel_i, midinote: midinote_i}
55
+ @playing_notes[so_id] = {channel: channel_i, midinote: midinote_i}
56
+ end
54
57
  end
55
58
  end
56
59
 
57
- def do_gate_off_change(so_ids)
58
- so_ids.each do |so_id|
59
- note = @playing_notes.delete(so_id)
60
- if note
61
- logger.info "MIDI Note off: #{[note[:channel], note[:midinote]]}"
62
- midi.note_off(@device, note[:channel], note[:midinote])
60
+ def do_gate_off_change(changes)
61
+ debug "Gate off change: #{changes}"
62
+
63
+ changes.each do |change|
64
+ change.fetch(:so_ids).each do |so_id|
65
+ note = @playing_notes.delete(so_id)
66
+ if note
67
+ debug "MIDI Note off: #{[note[:channel], note[:midinote]]}"
68
+ midi.note_off(@device, note[:channel], note[:midinote])
69
+ end
63
70
  end
64
71
  end
65
72
  end
66
73
 
67
74
  def do_state_change
68
- logger.info changed_state
69
- changed_state.each do |p, v|
75
+ debug "State change: #{changed_state}"
76
+
77
+ changed_state.each do |p, vs|
70
78
  cc_id = cc_parameters[p]
71
- midi.cc(@device, channel, cc_id, v) if cc_id
79
+ Array(vs).each { |v| midi.cc(@device, channel, cc_id, v.to_i) } if cc_id
72
80
  end
73
81
  end
74
82
 
@@ -80,5 +88,9 @@ module Xi::MIDI
80
88
  def midi
81
89
  Proxy.instance
82
90
  end
91
+
92
+ def latency_sec
93
+ 0.01
94
+ end
83
95
  end
84
96
  end
@@ -1,5 +1,5 @@
1
1
  module Xi
2
2
  module MIDI
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
@@ -0,0 +1,22 @@
1
+ module Xi::MIDI
2
+ module VolcaBass
3
+ CC = {
4
+ slide: 5,
5
+ expression: 11,
6
+ octave: 40,
7
+ lforate: 41,
8
+ lfoint: 42,
9
+ pitch1: 43,
10
+ pitch2: 44,
11
+ pitch3: 45,
12
+ attack: 46,
13
+ decay: 47,
14
+ cutoffegint: 48,
15
+ bgate: 49
16
+ }
17
+
18
+ def cc_parameters
19
+ CC
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,52 @@
1
+ module Xi::MIDI
2
+ module VolcaBeats
3
+ CC = {
4
+ lKick: 40,
5
+ lSnare: 41,
6
+ lLoTom: 42,
7
+ lHiTom: 43,
8
+ lClHat: 44,
9
+ lOpHat: 45,
10
+ lClap: 46,
11
+ lClaves: 47,
12
+ lAgogo: 48,
13
+ lCrash: 49,
14
+ sClap: 50,
15
+ sClaves: 51,
16
+ sAgogo: 52,
17
+ sCrash: 53,
18
+ stutterTime: 54,
19
+ stutterDepth: 55,
20
+ tomDecay: 56,
21
+ clHatDecay: 57,
22
+ opHatDecay: 58,
23
+ hatGrain: 59,
24
+ }
25
+
26
+ DRUMS = {
27
+ bd: 36,
28
+ sn: 38,
29
+ lt: 43,
30
+ ht: 50,
31
+ ch: 42,
32
+ oh: 46,
33
+ cp: 39,
34
+ cl: 75,
35
+ ag: 67,
36
+ cr: 49,
37
+ }
38
+
39
+ def cc_parameters
40
+ CC
41
+ end
42
+
43
+ def transform_state
44
+ super
45
+
46
+ if !changed_param?(:midinote) && changed_param?(:drum)
47
+ @state[:midinote] = Array(@state[:drum]).map { |n| DRUMS[n.to_sym] }.compact
48
+ @changed_params << :midinote
49
+ end
50
+ end
51
+ end
52
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xi-midi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damián Silvani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-13 00:00:00.000000000 Z
11
+ date: 2017-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,6 +84,8 @@ files:
84
84
  - lib/xi/midi/proxy.rb
85
85
  - lib/xi/midi/stream.rb
86
86
  - lib/xi/midi/version.rb
87
+ - lib/xi/midi/volca_bass.rb
88
+ - lib/xi/midi/volca_beats.rb
87
89
  - lib/xi/midi/volca_keys.rb
88
90
  - xi-midi.gemspec
89
91
  homepage: https://github.com/xi-livecode/xi-midi