Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Arpeggiator for Sounds
- #
- # An arpeggio is a sequence of notes.
- # These notes are a collection which is made up using a Scale, and Key.
- #
- # To find out which notes belong to an arpeggio, you take one of the rootnotes
- # (C, C#, D, D#, E, F, F#, G, G#, A, A# or B), and calculate which of the 12
- # notes belong to a scale, and select a couple or all notes of that scale.
- # The gem 'rb-music' implemented it as follows:
- #
- # NOTE_NAMES = ["F", "C", "G", "D", "A", "E", "B"]
- # ACCIDENTALS = ["bb", "b", "", "#", "x"]
- #
- # SCALES = {
- # major: [:major_second, :major_third, :fourth, :fifth, :major_sixth, :major_seventh],
- # natural_minor: [:major_second, :minor_third, :fourth, :fifth, :minor_sixth, :minor_seventh],
- # harmonic_minor: [:major_second, :minor_third, :fourth, :fifth, :minor_sixth, :major_seventh],
- # major_pentatonic: [:major_second, :major_third, :fifth, :major_sixth],
- # minor_pentatonic: [:minor_third, :fourth, :fifth, :minor_seventh],
- # blues: [:minor_third, :fourth, :augmented_fourth, :fifth, :minor_seventh],
- # dorian: [:major_second, :minor_third, :fourth, :fifth, :major_sixth, :minor_seventh],
- # phrygian: [:minor_second, :minor_third, :fourth, :fifth, :major_sixth, :minor_seventh],
- # lydian: [:major_second, :major_third, :augmented_fourth, :fifth, :major_sixth, :major_seventh],
- # mixolydian: [:major_second, :major_third, :fourth, :fifth, :major_sixth, :minor_seventh],
- # locrian: [:minor_second, :minor_third, :fourth, :diminished_fifth, :minor_sixth, :minor_seventh],
- # chromatic: [
- # :minor_second, :major_second, :minor_third, :major_third, :fourth, :diminished_fifth,
- # :fifth, :minor_sixth, :major_sixth, :minor_seventh, :major_seventh
- # # Method in sounds to play mp3
- # def play(name)
- # Thread.new { `mpg123 #{mp3_path name} > /dev/null 2>&1` }
- # end
- require 'rb-music'
- def print_arp (center = 4, key = "C", scale = "major", instrument= "piano")
- key += center.to_s
- arpeggio = Note.from_latin(key).scale(scale)
- puts "-"*52
- puts "The arpeggio of the key of #{key} in the #{scale} scale:"
- puts "-"*52
- arpeggio.each do |note|
- puts "Note name: #{note.latin }, Frequency: #{note.frequency.to_i} Hz"
- puts "Call in Sounds: 'play #{instrument}#{note.latin}#{center}.mp3'"
- end
- end
- print_arp(4, "C", "major", "piano")
- print_arp(7, "Ab", "phrygian", "piano")
- print_arp(5, "D#", "lydian", "guitar")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement