The code looks good, as a one-off quick-n-dirty get it done script If this is going to be used by others, and possibly re-used as part of a larger app than you have to think of how easy is it to integrate, and how easy is it to change?
Some things to consider: How is a user to know/learn what options are required/valid when running the command? What if you decide to add a GUI? What if you wanted to process more than 1 file? On Mon, Nov 19, 2012 at 10:37 AM, Ron S. <[email protected]> wrote: > I am an amateur programmer, and I feel I am missing something. Whenever > I've tried to understand certain aspects of programming, I often feel I > am just "missing something." And most instruction doesn't help (usually > because of overly clever examples... like: Okay class, today we are > talking about classes. So we'll use this class as an example. We'll > create a "class" called "class" and since classes have members we'll > create a member for each member of the class. Then we'll create a > variable in the class called "class" where we'll store how classy > everyone in the class is. Now... how many of you wear glasses?) > > I really just want my programs to DO SOMETHING. And I am trying to > develop a sort of automated analog synthesizer that works with files in > the .wav format. So my question is... what is WRONG with something like > this? > > #! usr/bin/env ruby > require 'wavefile' > include Math > > frames = (ARGV[0].to_f * 44100.0).to_i > volume = ARGV[1].to_f > freq = 44100.0 / (ARGV[2].to_f) > file = ARGV[3] > w = WaveFile.new(1, 44100, 16) > > (0..frames).each do > |frame| > w.sample_data[frame] = sin(frame * 2.0 * PI / freq) * volume * 32767 > end > > w.save(file) > > -- > Posted via http://www.ruby-forum.com/. > > -- You received this message because you are subscribed to the Google Groups ruby-talk-google group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at https://groups.google.com/d/forum/ruby-talk-google?hl=en
