Class: MusicalSpec::Player
- Inherits:
-
Object
- Object
- MusicalSpec::Player
- Defined in:
- lib/musical_spec/player.rb
Overview
This class plays the music using Bloopsaphone.
Instance Method Summary collapse
-
#initialize ⇒ Player
constructor
A new instance of Player.
-
#play(note) ⇒ Object
Takes a note string like “C4”.
Constructor Details
#initialize ⇒ Player
Returns a new instance of Player.
4 5 6 7 8 |
# File 'lib/musical_spec/player.rb', line 4 def initialize @sound = ONE_TRUE_BLOOPSAPHONE.sound(Bloops::SQUARE) @sound.sustain = 0.01 ONE_TRUE_BLOOPSAPHONE.tempo = 320 end |
Instance Method Details
#play(note) ⇒ Object
Takes a note string like “C4”.
11 12 13 14 15 16 |
# File 'lib/musical_spec/player.rb', line 11 def play(note) ONE_TRUE_BLOOPSAPHONE.clear ONE_TRUE_BLOOPSAPHONE.tune(@sound, note) ONE_TRUE_BLOOPSAPHONE.play sleep 0.01 while ! ONE_TRUE_BLOOPSAPHONE.stopped? end |