Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > [QUIZ] Music Theory (#229)

Reply
Thread Tools

[QUIZ] Music Theory (#229)

 
 
Daniel Moore
Guest
Posts: n/a
 
      02-26-2010
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

The three rules of Ruby Quiz:

1. Please do not post any solutions or spoiler discussion for this
quiz until 48 hours have elapsed from the time this message was
sent.

2. Support Ruby Quiz by submitting ideas and responses
as often as you can.

3. Enjoy!

Suggestion: A [QUIZ] in the subject of emails about the problem
helps everyone on Ruby Talk follow the discussion. Please reply to
the original quiz message, if you can.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

RSS Feed: http://rubyquiz.strd6.com/quizzes.rss

Suggestions?: http://rubyquiz.strd6.com/suggestions

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

## Music Theory (#229)

Do-Re-Me Rubyists,

I have a musician friend, let's call him Steve. Steve wants to be a
legendary guitarist. He practices every day, learning new chords and
techniques. But he has a problem.

Steve bought all the books, but it's too much trouble to flip through
them when he's practicing. He tried all sorts of ways to solve this
problem: adhesive notes that adhered to everything, big music stands
that kept getting knocked over, websites with loud and annoying video
advertisements... everything. He even tried enlisting the help of his
trusty cat, Pajamas, to turn the pages, yet nothing worked.

He's trying to learn Amaj7 so he can be cool like his hero, Herman Li,
but Pajamas clawed out that part of his book. Steve is programmer, so
he knows that when solving a problem it should be solved once and
forever. Steve wants to write a program where someone can type in
Amaj7 and see the notes that comprise the chord. Not only Amaj7 but
Dsus2 as well. In fact, any chord at all.

Steve, because he is a proper programmer, is lazy. He came to me and
asked if I could send this out on the "weekly" Ruby Quiz. Anything to
help a friend!

Your task is to create a program that will accept strings like: Amaj7,
Dsus2, Aminor, C, C9, G#dim, Ebadd9, etc. The output will be the notes
that make up the chord, for example

Cmajor => C E G
Ebdim7 => Eb Gb A C

Have fun! And thanks for helping Steve out!

--
-Daniel
http://rubyquiz.strd6.com

 
Reply With Quote
 
 
 
 
Brian Candler
Guest
Posts: n/a
 
      03-01-2010
Evan Hanson wrote:
> Actually, one of the toughest parts
> about
> this problem was deciding what degrees of the chord are implied by a
> given
> symbol. I'm a jazz musician, and we just play whatever the hell we want,
> so I
> wasn't sure on the specifics of a few of them.


I learned classical at school, so had to unlearn a load of stuff when
trying to play jazz.

OUT:
Cmajor => C E G

IN:
Cmajor => E B or B E
(not C: that's the bass player's job)
(not G: perfect 5th just reinforces the root)
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Evan Hanson
Guest
Posts: n/a
 
      03-02-2010
Yeah, 3 & 7 decide the nature of the chord. Ditch everything but that,
then add extensions (at least for the instruments that carry the
harmony). You took a better musical route; I learned jazz first so my
theory is good but my knowledge of the traditional ruleset is a bit
lacking.

Incidentally, I just tested my code on my other machine and got a
"warning: parenthesize argument(s) for future version"... I hope
there's no seachange in syntax on the way? I'm assuming this is just
for ambiguities?

On Mon, Mar 1, 2010 at 3:02 PM, Brian Candler <(E-Mail Removed)> wrote:
> Evan Hanson wrote:
>> Actually, one of the toughest parts
>> about
>> this problem was deciding what degrees of the chord are implied by a
>> given
>> symbol. I'm a jazz musician, and we just play whatever the hell we want,
>> so I
>> wasn't sure on the specifics of a few of them.

>
> I learned classical at school, so had to unlearn a load of stuff when
> trying to play jazz.
>
> OUT:
> Cmajor =3D> C E G
>
> IN:
> Cmajor =3D> E B =A0or =A0B E
> =A0(not C: that's the bass player's job)
> =A0(not G: perfect 5th just reinforces the root)
> --
> Posted via http://www.ruby-forum.com/.
>
>


 
Reply With Quote
 
Brian Candler
Guest
Posts: n/a
 
      03-02-2010
Evan Hanson wrote:
> Incidentally, I just tested my code on my other machine and got a
> "warning: parenthesize argument(s) for future version"... I hope
> there's no seachange in syntax on the way? I'm assuming this is just
> for ambiguities?


The message suggests that the parsing might change. I suspect it's
unlikely, but it's safer to add the parentheses as it suggests.

There are all sorts of ambiguities arising from poetry mode. For
example,

puts (1-2).abs
and
puts(1-2).abs

are parsed differently.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Rick DeNatale
Guest
Posts: n/a
 
      03-02-2010
On Mon, Mar 1, 2010 at 4:02 PM, Brian Candler <(E-Mail Removed)> wrote:
> Evan Hanson wrote:
>> Actually, one of the toughest parts
>> about
>> this problem was deciding what degrees of the chord are implied by a
>> given
>> symbol. I'm a jazz musician, and we just play whatever the hell we want,
>> so I
>> wasn't sure on the specifics of a few of them.

>
> I learned classical at school, so had to unlearn a load of stuff when
> trying to play jazz.
>
> OUT:
> Cmajor =3D> C E G
>
> IN:
> Cmajor =3D> E B =A0or =A0B E
> =A0(not C: that's the bass player's job)
> =A0(not G: perfect 5th just reinforces the root)


So you're saying that to a Jazz player Cmajor has a note from Cmajor7 ?



--=20
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/pers...-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

 
Reply With Quote
 
Brian Candler
Guest
Posts: n/a
 
      03-02-2010
Rick Denatale wrote:
> So you're saying that to a Jazz player Cmajor has a note from Cmajor7 ?


Yes. I had to unlearn a lot of stuff

As Evan said, it's the 3rd and 7th which define the nature of the chord,
so there are four basic shells (minor or major 3rd, together with minor
or major 7th). You can put them either way up, which allows for smooth
progressions [1]

And apart from a couple of rules [2], you can add any other notes of the
scale to make a fuller chord. The fact that harmony comes from scales
and not triads was a big revelation to me. Another was the existence of
lots of other scales like the Lydian.

Apologies if this is going way off-topic

Cheers,

Brian.

[1] e.g. Dm -> G7 -> C could be (F+C), (F+B), (E+B)

[2] Don't play a perfect 4th with a major 3rd - it jars. And keep either
the 3rd or 7th towards the bottom of the voicing.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Jim Maher
Guest
Posts: n/a
 
      03-02-2010
Brian Candler wrote:
>
> Apologies if this is going way off-topic
>
> Cheers,
>
> Brian.
>


I love this topic - because of the music theory!

I've barely started learning Ruby, so I'm not playing along with the
quiz.

I don't know music theory - AT ALL - but I'd love to learn. Can you
guys recommend a couple great books (e.g., textbooks)?

Thanks,

Jim Maher
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Brian Candler
Guest
Posts: n/a
 
      03-02-2010
Jim Maher wrote:
> I don't know music theory - AT ALL - but I'd love to learn. Can you
> guys recommend a couple great books (e.g., textbooks)?


The jazz I learned mostly through classes, although I have a couple of
chord progression books. The classical theory was many years ago at
school - I think the main tome was called "The Rudiments of Music"
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Evan Hanson
Guest
Posts: n/a
 
      03-02-2010
If you're interested in jazz specifically (though if you learn that
picking up the other styles becomes much easier), look for books by
Mark Levine -- I have the Jazz Theory Book and the Jazz Piano Book,
both are top-notch, and the former is considered by many to be the
"Bible" of jazz, so to speak.

On Tue, Mar 2, 2010 at 10:10 AM, Jim Maher <(E-Mail Removed)> wrote:
> Brian Candler wrote:
>>
>> Apologies if this is going way off-topic
>>
>> Cheers,
>>
>> Brian.
>>

>
> I love this topic - because of the music theory!
>
> I've barely started learning Ruby, so I'm not playing along with the
> quiz.
>
> I don't know music theory - AT ALL - but I'd love to learn. =A0Can you
> guys recommend a couple great books (e.g., textbooks)?
>
> Thanks,
>
> Jim Maher
> --
> Posted via http://www.ruby-forum.com/.
>
>


 
Reply With Quote
 
David Springer
Guest
Posts: n/a
 
      03-02-2010
OK

Here is my solution.
I'm rather new to Ruby.
So this may look more C-like than Ruby-ish.
I am not a musician.
It should be easy to add additional chords.

I could not come up with a good way to decide wich of two equivalent
notes to display.

I'm not sure about the etiquette of attaching a non-compressed file.
Right now I am working under Windows XP.

Not sure how to deliver a .tar.gz file under Windows.

I probably could just do a .z file though.

I was fun AND consumed way too much of my free time.

Attachments:
http://www.ruby-forum.com/attachment/4531/Chords_DNS.rb

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Music Theory Programming" Google Group Omar Python 2 10-28-2006 03:02 AM
"Music Theory Programming" Google Group Omar HTML 0 10-27-2006 07:36 PM
wma / drm / music download theory help! =?Utf-8?B?ZGhucml2ZXJzaWRl?= ASP .Net 1 03-06-2005 07:18 PM
Saving website music / identify music berksposter Computer Support 6 10-19-2004 03:29 AM
New book on Information Theory and State-of-the-art Coding Theory David MacKay VOIP 0 11-05-2003 10:42 PM



Advertisments