Music knowledge representation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mr.SpOOn

    Music knowledge representation

    Hi,
    I'm working on an application to analyse music (melodies, chord sequences etc.)

    I need classes to represent different musical entities. I'm using a
    class Note to represent all the notes. Inside it stores the name of
    the natural version of the note (C, D, E, F...) and an integer to
    calculate the accidentals.

    Then I have a class Pitch, to represent the different 12 pitch
    classes, because different notes, such as C# and Db, belong to the
    same pitch class.

    In these classes I also have some arithmetic method to perform
    additions or subtractions between pitches and integers.

    I also need to represent intervals between notes. An interval must
    have a degree (first, second, third), that may be represented with a
    simple integer and a size counted in semitones. Then, with these
    informations it can retrieve its name, for example: perfect fifth.

    The degree is calculated between natural notes. So the degree of
    Interval(C, E) is "third", or 3. This may be simple, if I put the
    notes in an ordered sequence. But, when I have to calculate, for
    example Interval(E, C). It should count till the end of the sequence,
    so if I have:

    C D E F G A B

    after the B it should continue with C. I'm not sure how to implement
    this. Is there a suitable data structure for this purpose?
  • Aaron \Castironpi\ Brady

    #2
    Re: Music knowledge representation

    On Sep 28, 9:37 am, Mr.SpOOn <mr.spoo...@gma il.comwrote:
    Hi,
    I'm working on an application to analyse music (melodies, chord sequencesetc.)
    >
    I need classes to represent different musical entities. I'm using a
    class Note to represent all the notes. Inside it stores the name of
    the natural version of the note (C, D, E, F...) and an integer to
    calculate the accidentals.
    >
    Then I have a class Pitch, to represent the different 12 pitch
    classes, because different notes, such as C# and Db, belong to the
    same pitch class.
    >
    In these classes I also have some arithmetic method to perform
    additions or subtractions between pitches and integers.
    >
    I also need to represent intervals between notes. An interval must
    have a degree (first, second, third), that may be represented with a
    simple integer and a size counted in semitones. Then, with these
    informations it can retrieve its name, for example: perfect fifth.
    >
    The degree is calculated between natural notes. So the degree of
    Interval(C, E) is "third", or 3. This may be simple, if I put the
    notes in an ordered sequence. But, when I have to calculate, for
    example Interval(E, C). It should count till the end of the sequence,
    so if I have:
    >
    C D E F G A B
    >
    after the B it should continue with C. I'm not sure how to implement
    this. Is there a suitable data structure for this purpose?
    Hi,

    Here is a link to someone else's design they asked about on the
    newsgroup a couple weeks ago.


    Comment

    • Mr.SpOOn

      #3
      Re: Music knowledge representation

      On Sun, Sep 28, 2008 at 8:59 PM, Aaron Castironpi Brady
      <castironpi@gma il.comwrote:
      Here is a link to someone else's design they asked about on the
      newsgroup a couple weeks ago.
      >
      http://groups.google.com/group/comp....1cba3084b984dc
      :D
      It's always me.

      I think my question is more specific. I need some sort of cycle.

      So if I have a list with A, B, C, D, when I iter over it I need to get
      an A after the D.

      Comment

      • Mark Tolonen

        #4
        Re: Music knowledge representation


        "Mr.SpOOn" <mr.spoon21@gma il.comwrote in message
        news:mailman.16 33.1222628890.3 487.python-list@python.org ...
        On Sun, Sep 28, 2008 at 8:59 PM, Aaron Castironpi Brady
        <castironpi@gma il.comwrote:
        >
        >Here is a link to someone else's design they asked about on the
        >newsgroup a couple weeks ago.
        >>
        >http://groups.google.com/group/comp....1cba3084b984dc
        >
        :D
        It's always me.
        >
        I think my question is more specific. I need some sort of cycle.
        >
        So if I have a list with A, B, C, D, when I iter over it I need to get
        an A after the D.
        Check out itertools.cycle :
        >>x=itertools.c ycle('ABCDEFG')
        >>x.next()
        'A'
        >>x.next()
        'B'
        >>x.next()
        'C'
        >>x.next()
        'D'
        >>x.next()
        'E'
        >>x.next()
        'F'
        >>x.next()
        'G'
        >>x.next()
        'A'
        >>x.next()
        'B'

        -Mark

        Comment

        • Aaron \Castironpi\ Brady

          #5
          Re: Music knowledge representation

          On Sep 28, 2:08 pm, Mr.SpOOn <mr.spoo...@gma il.comwrote:
          On Sun, Sep 28, 2008 at 8:59 PM, Aaron Castironpi Brady
          >
          <castiro...@gma il.comwrote:
          Here is a link to someone else's design they asked about on the
          newsgroup a couple weeks ago.
          >>
          :D
          It's always me.
          >
          I think my question is more specific. I need some sort of cycle.
          >
          So if I have a list with A, B, C, D, when I iter over it I need to get
          an A after the D.
          This one was an easy guess:

          cycle( iterable)

          Make an iterator returning elements from the iterable and saving a
          copy of each. When the iterable is exhausted, return elements from the
          saved copy. Repeats indefinitely.

          Comment

          Working...