WEB XML question.. music?

Discussion in 'OT Technology' started by White Stormy, Dec 20, 2008.

  1. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,489
    Likes Received:
    70
    Location:
    Sparkopolis
    XML is useful because it separates data.. but what about data that has an order? do you just put an attribute/whatever in the xml of each class for a number that represents order?

    like if I wanted to convert sheet music to XML.. the notes have a certain order

    I haven't read much/anything about XML, but from what I remember/have seen.. I guess I could make a class for each note on the staff.. and then do xml classes/groups that basically just call an instance of the note and then give it a position in the whole sheet of notes?
     
  2. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,489
    Likes Received:
    70
    Location:
    Sparkopolis
    that probably doesn't make sense. I should read more about XML, I guess
     
  3. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,489
    Likes Received:
    70
    Location:
    Sparkopolis
    I'm very bored.
     
  4. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,489
    Likes Received:
    70
    Location:
    Sparkopolis
    so with the example on wikipedia..
    Code:
     <recipe name="bread" prep_time="5 mins" cook_time="3 hours">
       <title>Basic bread</title>
       <ingredient amount="8" unit="dL">Flour</ingredient>
       <ingredient amount="10" unit="grams">Yeast</ingredient>
       <ingredient amount="4" unit="dL" state="warm">Water</ingredient>
       <ingredient amount="1" unit="teaspoon">Salt</ingredient>
       <instructions>
         <step>Mix all ingredients together.</step>
         <step>Knead thoroughly.</step>
         <step>Cover with a cloth, and leave for one hour in warm room.</step>
         <step>Knead again.</step>
         <step>Place in a bread baking tin.</step>
         <step>Cover with a cloth, and leave for one hour in warm room.</step>
         <step>Bake in the oven at 180(degrees)C for 30 minutes.</step>
       </instructions>
     </recipe>
    
    I guess I would just do like..
    <note>F</note>
    <note>F</note>
    <note>G</note>
    <note>B</note>
    <note>A</note>

    and note could have an attribute for the length of the note. think that's probably the best way? or should I also include an attribute for order?
     
  5. whup

    whup I wish you had children and.. so that I could step

    Joined:
    Feb 12, 2007
    Messages:
    1,603
    Likes Received:
    0
    You wouldn't have to worry about any order, as long as everything appears in the file in the order it should. You wouldn't need it unless you want to dynamically sort things.
     
  6. whup

    whup I wish you had children and.. so that I could step

    Joined:
    Feb 12, 2007
    Messages:
    1,603
    Likes Received:
    0
    Are you actually wanting to write this music-to-xml thing, or are you using that as an example?

    Notating a piece in XML would be pretty complex.

    You need the bpm of the piece, the key, and you can't just have notes, you need to specify the octave as well, then the duration.

    Then on top of the key you have sharps, flats, naturals (and how they work in the context of a bar). Then dynamics and accents like crescendo, staccato.

    You'd probably want to break things up in bars; staves wouldn't be necessary I think. But you need ability to have repeats, codas.

    Then if this is instrument-specific, you need to take into account fingerings, tunings, hand positions and instrument-specific techniques e.g. hammer-ons, pull-offs.

    Sorry I don't mean to put you off, just it's pretty ambitious!

    At the very simplest you could have the key, have the the bpm timing, break it up into bars. Then you put in the notes+octave+duration + optional sharp/flat/natural.

    As a quick example:

    Code:
    <composition>
        <info>
            <author>Blah</author>
        </info>
        <notation key="C" bpm="120" time-signature="4/4"/>
        <piece>
            <section name="intro" repeat="2"><!-- A section could be 1 or more bars that you could repeat for example -->
                <bar><note octave="1" duration="quaver">C</note></bar>
                <bar><note octave="2" duration="quaver">E</note></bar>
                etc...
            </section>
            <!-- Then you have just the bars going without putting them in a section -->
            <bar><note octave="-1" duration="semi-tone">D</note></bar><!-- the octave number could match the octave above/below middle C -->
            <section same-as-section-named="intro" repeat="1"/><!-- Repeat the same intro once, without having to re-write it -->
        </piece>
    </composition>
    
    You don't need to put in any order, as the XML file should be read sequentially, and results returned sequentially unless otherwise specified.

    It's up to you really, there's lot you can do. It's a matter of preference what you think should be attributes, and what should be elements.
     
  7. Falconer

    Falconer OT Supporter

    Joined:
    Jun 23, 2006
    Messages:
    65,506
    Likes Received:
    1
    Wow, I remember writing music in Hypercard on old Mac platforms.

    You had to list every note, duration, etc., for entire songs. It took forever, but we would write like "Come As You Are" by Nirvana :rofl:
     
  8. Falconer

    Falconer OT Supporter

    Joined:
    Jun 23, 2006
    Messages:
    65,506
    Likes Received:
    1
    Does this make websites play music?

    Why not just write a .mid files and embed it?
     
  9. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,489
    Likes Received:
    70
    Location:
    Sparkopolis
    you could display sheet music online using just a CSS sheet to style the XML
     
  10. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,489
    Likes Received:
    70
    Location:
    Sparkopolis
    :bowdown:

    I'd like to actually do it.

    yeah I was thinking about using diff tags for each voice/instrument, so you could have a whole arrangement in one XML file and use a form + CSS to show only specific ones or the whole thing, etc.

    I don't know anything about guitar, but accents shouldn't really be that bad
     
  11. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,489
    Likes Received:
    70
    Location:
    Sparkopolis
    and I could even put vocals in..
     
  12. Rawrsome

    Rawrsome RAWR

    Joined:
    Oct 6, 2003
    Messages:
    3,072
    Likes Received:
    0
    Location:
    Santa Barbara, CA / Boston, MA
    This is a badass idea actually. It would allow people to format the music however they want, or even use to play the notes like midi. Interesting...
     
  13. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,489
    Likes Received:
    70
    Location:
    Sparkopolis
    I came up with the idea back in June but got very very distracted by other less awesome ideas :o
     
  14. Falconer

    Falconer OT Supporter

    Joined:
    Jun 23, 2006
    Messages:
    65,506
    Likes Received:
    1
    please post a page with an example of this :)
     

Share This Page