Archaeopteryx

Making Music With Ruby

Ive been looking at and ive been playing around with creating my own sequencer setup for playing text_2_midi live through the use of Archaeopteryx

I was wondering if you had the chance to look at it its a very simple concept and below is the code i used to convert the text 2 numbers

if you run the program it lets you type what every text you want when you press enter it spits out the number these are the numbers i want to be converted to midi basical I want to be able to type live and every time enter is pressed it sends it to a channel in the sequencer ex. channel 1 but only after you press enter so the user can fix misspelled words before send it.

# The Code

x = true
until x == false do
text=gets.upcase.chomp
text_array = [] # for storing channel 1 data
# Converts given text into a Number !!
text.each_byte {|c| text_array << c-5} # -5 used to make the letter a #default to midi number 60 or C note
channel_1 = text_array
# Just for visual proof that it converts
puts "Channel 1"
p channel_1
end

I have used this code in several other text 2 midi standalone apps I have written that and have more advanced conversion setups that allow importing of txt files and even converting rss feeds to midi but just like to to very basic working first then I'll expand on it.

any help or ideas would be great

Gabriel

Share

Reply to This

Replies to This Discussion

OK, so what I would recommend is that you basically plagiarize eval_style.rb and db_drum_definition.rb.

eval_style (plus all the stuff in lib) gets a loop going where a file is perpetually re-evaluated.

db_drum_definition.rb is that file.

Arx is really kind of a beast these days, due to edits I made right before Burning Man to enable some new features. It doesn't really have a nice user-friendly API for this sort of thing. However, I would basically do what you're asking for with a db_drum_definition-style file-reloader, like this:

@notes = []
def convert(word)

word.each_byte do |byte|

@notes << Note.new(:channel => 1, note_number => word -5, :duration => 0.25)

end

end

text = %(blah blah blah)

text.each {|word| convert(word)}
@notes



This is just pseudocode, but it'd probably work. The magic happens with @notes - the file to eval is expected to return an array of notes, which is to say Arx Note objects.

Reply to This

Thanks for the help I went though and looked at the evol file

add i modiifed like this

require 'lib/archaeopteryx'

Arkx.new(:clock => Clock.new(167),
:measures => 4,
:logging => true,
:evil_timer_offset_wtf => 0.2,
Mix.new(:text_convert => "text_2_reason.rb")).go

so it should call text_2_reason file instead which i wrote like this

word = "hello Ruby Live Music"

@notes = []


def note(midi_note_number)
Note.create(:channel => 1,
:number => midi_note_number,
:duration => 0.25,
:velocity => 100 + rand(27))
end

def convert(word)
word.each_byte do |byte|
@notes << Note.new(:channel => 1, note_number => word -5, :duration => 0.25)
end
end

but still not working properly i hard coded a word phrase

I also read the practical ruby projects book on ruby music copied the LiveMIDI file and started to play with that i have it generating a nd playing midi but still have trouble getting it to understand the text conversion.

Thanks Again Gabriel






Giles said:
OK, so what I would recommend is that you basically plagiarize eval_style.rb and db_drum_definition.rb.
eval_style (plus all the stuff in lib) gets a loop going where a file is perpetually re-evaluated. db_drum_definition.rb is that file.

Arx is really kind of a beast these days, due to edits I made right before Burning Man to enable some new features. It doesn't really have a nice user-friendly API for this sort of thing. However, I would basically do what you're asking for with a db_drum_definition-style file-reloader, like this:

@notes = []
def convert(word)

word.each_byte do |byte|

@notes << Note.new(:channel => 1, note_number => word -5, :duration => 0.25)

end

end

text = %(blah blah blah)

text.each {|word| convert(word)}
@notes



This is just pseudocode, but it'd probably work. The magic happens with @notes - the file to eval is expected to return an array of notes, which is to say Arx Note objects.

Reply to This

dude I don't know, but I noticed you're not returning @notes. you need to return an array of notes at the end of your file, assuming you built that :text_convert stuff on the model of the :drumfile stuff. you're populating the var but you're not returning it.

HTH

Reply to This

Reply to This

RSS

Badge

Loading…

© 2009   Created by Giles on Ning.   Create a Ning Network!

Badges  |  Report an Issue  |  Privacy  |  Terms of Service