Drawing music waves from XML File

edited May 2016 in Questions about Code

Hello, I draw Lines of notes from an XML file. But the lines are not correct!?

Why they draw up and down? They would be more represented in waveform?

You can see 2 images: The notes in orange and the reaction with Processing.

Here the code:

**The code: **

XML xml;
int stepWert = 10;
float summe;
String stepNote;
String octaveWert;
String durationWert;
String instrumentWert;
String c = "C";
String d = "D";
String e = "E";
String f = "F";
String g = "G";
String a = "A";
String h = "H";
String b = "B";
float x = 0;

import processing.pdf.*;

void setup() {
  beginRecord (PDF, "vektoren.pdf");
  size (80500, 700);
  background (0);
  noFill();
  stroke(250, 187, 0);
  strokeWeight(1);

  //Laden des XML Dokuments
  xml = loadXML("score-partwise.xml");

  //Filtern der für den Sketch wichtigen Daten
  // aus dem geladenen XML Dokument
  XML[] instrument = xml.getChildren("part");
  XML[] step = xml.getChildren("part/measure/note/pitch/step");
  XML[] octave = xml.getChildren("part/measure/note/pitch/octave");
  XML[] duration = xml.getChildren("part/measure/note/duration");

  for (int n = 0; n < 1; n++) {
    instrumentWert = instrument[n].getString("id");
  }

  //für jeden Datensatz im XML Dokument
beginShape();
for (int n = 0; n < step.length; n++) {
  stepNote = step[n].getContent();
    curveVertex (x, height-summe);
    stepNote = step[n].getContent ();
    octaveWert = octave[n].getContent ();
    durationWert = duration[n].getContent ();
    println ("step" + stepNote + "octave" + octaveWert + "duration" + durationWert 
    + "instrument" + instrumentWert);

    if (stepNote.equals(c)) stepWert = 1;
    if (stepNote.equals(d)) stepWert = 2;
    if (stepNote.equals(e)) stepWert = 3;
    if (stepNote.equals(f)) stepWert = 4;
    if (stepNote.equals(g)) stepWert = 5;
    if (stepNote.equals(a)) stepWert = 6;
    if (stepNote.equals(h)) stepWert = 7;
    if (stepNote.equals(b)) stepWert = 8;

    println ("stepWert" + stepWert);

    summe = stepWert*40 + int(octaveWert)*40;
    println ("Summe" + summe);

    x+=7;
}
endShape();
endRecord();   
}

01_Anfang_Klarinette

01_Anfang_Klarinette_processing

Answers

Sign In or Register to comment.