Package ru.mail.teodorgig.mididermi.base

Examples of ru.mail.teodorgig.mididermi.base.Note


        Melody melody = new Melody();
        melody.setId(result.getLong("system_id"));
        String sequence = result.getString("sequence");
        StringTokenizer tokenizer = new StringTokenizer(sequence, " ", false);
        while (tokenizer.hasMoreElements()) {
          Note note = new Note();
          try {
            note.setNote((new Integer((String) tokenizer.nextElement())).intValue());
            note.setOffset((new Integer((String) tokenizer.nextElement())).intValue());
            note.setDuration((new Integer((String) tokenizer.nextElement())).intValue());
            note.setVelocity((new Integer((String) tokenizer.nextElement())).intValue());
          } catch (Exception ex) {
            ex.printStackTrace();
          }
          melody.addNote(note);
        }
View Full Code Here


   */
  public static Melody provide(int length) {
    Melody melody = new Melody();

    // TODO Better fractal formula can be implemented.
    Note next = null;
    Note previous = null;
    for (int i = 0; i < length; i++) {
      next = Note.provideRandom();

      if (i > 0 && previous.getNote() > next.getNote()) {
        next.setNote(next.getNote() + 1);
      } else if (i > 0 && previous.getNote() < next.getNote()) {
        next.setNote(next.getNote() - 1);
      }

      melody.addNote(next);
      previous = next;
View Full Code Here

    } catch (NumberFormatException ex) {
      throw (new NotValidDescriptorFileException("Note duration is not correct number [" + token + "]!"));
    }

    // TODO Better way to select note velocity is needed.
    return (new Note(note, 0, duration, 64));
  }
View Full Code Here

    /*
     * All notes are fowling after timber.
     */
    while (tokenizer.hasMoreTokens() == true) {
      Note note = parseNote(tokenizer.nextToken());

      // TODO It is not clear how much time is between two notes.
      note.setOffset(timeCounter);

      melody.addNote(note);

      timeCounter += note.getDuration();
    }

    return (melody);
  }
View Full Code Here

TOP

Related Classes of ru.mail.teodorgig.mididermi.base.Note

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.