Skip to content

Commit

Permalink
Merge pull request #9 from arirusso/0.4.0
Browse files Browse the repository at this point in the history
0.4.0
  • Loading branch information
arirusso committed Feb 18, 2022
2 parents 6644451 + 48df9cc commit 109defe
Show file tree
Hide file tree
Showing 22 changed files with 425 additions and 447 deletions.
13 changes: 6 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
source "https://rubygems.org"
# frozen_string_literal: true

group :test do
gem "mocha"
gem "rake"
gem "shoulda-context"
end
source 'https://rubygems.org'

gem "ffi"
gem 'ffi', '~> 1.15', '>= 1.15.5'
gem 'rake', '~> 13.0', '>= 13.0.6', groups: %i[development test]
gem 'rspec', '~> 3.11', '>= 3.11.0', groups: %i[test]
gem 'rubocop', '~> 1.10', '>= 1.10.0', groups: %i[development test], require: false
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2010-2017 Ari Russo
Copyright 2010-2022 Ari Russo

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ Otherwise

Apache 2.0, See the file LICENSE

Copyright (c) 2010-2017 Ari Russo
Copyright (c) 2010-2022 Ari Russo
17 changes: 9 additions & 8 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
require "rake"
require "rake/testtask"
# frozen_string_literal: true

Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.test_files = FileList["test/**/*_test.rb"]
t.verbose = true
end
begin
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

task :default => [:test]
task default: :spec
rescue LoadError
# no rspec available
end
11 changes: 5 additions & 6 deletions examples/input.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

dir = File.dirname(File.expand_path(__FILE__))
$LOAD_PATH.unshift dir + "/../lib"
$LOAD_PATH.unshift "#{dir}/../lib"

require "alsa-rawmidi"
require 'alsa-rawmidi'

# Selects the first MIDI input and prints the first 10 messages it receives to standard out

Expand All @@ -13,14 +14,12 @@
# or amidi -l from the command line

AlsaRawMIDI::Input.first.open do |input|

puts "send some MIDI to your input now..."
puts 'send some MIDI to your input now...'

num_messages.times do
m = input.gets
puts(m)
end

puts "finished"

puts 'finished'
end
7 changes: 4 additions & 3 deletions examples/list_devices.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

dir = File.dirname(File.expand_path(__FILE__))
$LOAD_PATH.unshift dir + "/../lib"
$LOAD_PATH.unshift "#{dir}/../lib"

# Lists all of the available MIDI devices

require "alsa-rawmidi"
require "pp"
require 'alsa-rawmidi'
require 'pp'

pp AlsaRawMIDI::Device.all_by_type
21 changes: 8 additions & 13 deletions examples/output.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

dir = File.dirname(File.expand_path(__FILE__))
$LOAD_PATH.unshift dir + "/../lib"
$LOAD_PATH.unshift "#{dir}/../lib"

require "alsa-rawmidi"
require 'alsa-rawmidi'

# Selects the first MIDI output and sends some arpeggiated chords to it

Expand All @@ -14,23 +15,17 @@
# AlsaRawMIDI::Device.all.to_s will list your midi devices
# or amidi -l from the command line

puts "Press Control-C to exit..."
puts 'Press Control-C to exit...'

AlsaRawMIDI::Output.first.open do |output|

loop do
(0..((octaves-1)*12)).step(12) do |oct|

(0..((octaves - 1) * 12)).step(12) do |oct|
notes.each do |note|

output.puts(0x90, note + oct, 100) # note on
sleep(duration) # wait
output.puts(0x80, note + oct, 100) # note off
output.puts(0x90, note + oct, 100) # NOTE: on
sleep(duration) # wait
output.puts(0x80, note + oct, 100) # NOTE: off
sleep(duration)

end

end
end

end
5 changes: 3 additions & 2 deletions examples/sysex_output.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

dir = File.dirname(File.expand_path(__FILE__))
$LOAD_PATH.unshift dir + "/../lib"
$LOAD_PATH.unshift "#{dir}/../lib"

# Sends a MIDI system exclusive message to the selected output

require "alsa-rawmidi"
require 'alsa-rawmidi'

output = AlsaRawMIDI::Output.first
sysex_msg = [0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7]
Expand Down
20 changes: 11 additions & 9 deletions lib/alsa-rawmidi.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
# frozen_string_literal: true

#
# alsa-rawmidi
# ALSA Driver Interface
#
# (c) 2010-2014 Ari Russo
# (c) 2010-2022 Ari Russo
# Licensed under Apache 2.0
# https://github.com/arirusso/alsa-rawmidi
#

# libs
require "ffi"
require 'ffi'

# modules
require "alsa-rawmidi/api"
require "alsa-rawmidi/device"
require "alsa-rawmidi/version"
require 'alsa-rawmidi/api'
require 'alsa-rawmidi/device'
require 'alsa-rawmidi/type_conversion'
require 'alsa-rawmidi/version'

# class
require "alsa-rawmidi/input"
require "alsa-rawmidi/output"
require "alsa-rawmidi/soundcard"
require 'alsa-rawmidi/input'
require 'alsa-rawmidi/output'
require 'alsa-rawmidi/soundcard'

module AlsaRawMIDI

end

0 comments on commit 109defe

Please sign in to comment.