Search in sources :

Example 1 with Pitch

use of com.xenoage.zong.core.music.Pitch in project Zong by Xenoage.

the class Base42b method getExpectedStaves.

/**
 * Gets the expected musical data, but without the dynamics, articulations and slurs
 * and also without the clef changes.
 */
static Staff[] getExpectedStaves() {
    Score score = ScoreFactory.create1Staff();
    Cursor cursor = new Cursor(score, mp0, true);
    cursor.write(new TimeSignature(TimeType.Companion.getTime_6_8()));
    // staff 1, measure 0
    cursor.write(chord(Companion.pi('F', 0, 4), Companion.fr(1, 8)));
    cursor.write(chord(Companion.pi('D', 0, 4), Companion.fr(1, 8)));
    cursor.write(chord(Companion.pi('B', 0, 3), Companion.fr(1, 8)));
    cursor.write(chord(Companion.pi('G', 0, 3), Companion.fr(1, 8)));
    cursor.write(chord(Companion.pi('F', 0, 3), Companion.fr(1, 4)));
    // staff 1, measure 1
    cursor.write(chord(Companion.pi('E', 0, 5), Companion.fr(1, 8)));
    cursor.write(chord(Companion.pi('C', 0, 5), Companion.fr(1, 8)));
    cursor.write(chord(Companion.pi('G', 0, 4), Companion.fr(1, 8)));
    cursor.write(chord(Companion.pi('G', 0, 4), Companion.fr(1, 8)));
    cursor.write(chord(Companion.pi('F', 0, 4), Companion.fr(1, 4)));
    // staff 1, measure 0
    cursor.setMp(atElement(1, 0, 0, 0));
    cursor.write(new Rest(Companion.fr(1, 8)));
    cursor.write(chord(Companion.pi('G', 0, 2), Companion.fr(1, 8)));
    cursor.write(chord(Companion.pi('G', 0, 2), Companion.fr(1, 8)));
    cursor.write(chord(Companion.pi('G', 0, 2), Companion.fr(1, 8)));
    cursor.write(chord(Companion.pi('A', 0, 2), Companion.fr(1, 16)));
    cursor.write(chord(Companion.pi('G', 0, 2), Companion.fr(1, 16)));
    cursor.write(chord(Companion.pi('F', 1, 2), Companion.fr(1, 16)));
    cursor.write(chord(Companion.pi('G', 0, 2), Companion.fr(1, 16)));
    // staff 1, measure 1
    cursor.write(chord(new Pitch[] { Companion.pi('C', 0, 3), Companion.pi('E', 0, 3), Companion.pi('G', 0, 3), Companion.pi('C', 0, 4) }, Companion.fr(1, 4)));
    cursor.write(new Rest(Companion.fr(1, 8)));
    cursor.write(new Rest(Companion.fr(1, 4)));
    cursor.write(chord(Companion.pi('G', 0, 3), Companion.fr(1, 8)));
    return new Staff[] { score.getStaff(0), score.getStaff(1) };
}
Also used : Score(com.xenoage.zong.core.Score) Rest(com.xenoage.zong.core.music.rest.Rest) Staff(com.xenoage.zong.core.music.Staff) Pitch(com.xenoage.zong.core.music.Pitch) Cursor(com.xenoage.zong.io.selection.Cursor) TimeSignature(com.xenoage.zong.core.music.time.TimeSignature)

Example 2 with Pitch

use of com.xenoage.zong.core.music.Pitch in project Zong by Xenoage.

the class MidiChordPlayer method playNote.

/**
 * Plays a single note.
 */
public void playNote(Pitch pitch, Instrument instrument, byte velocity) {
    if (instrument instanceof PitchedInstrument)
        setMidiprogram(((PitchedInstrument) instrument).getMidiProgram());
    int midipitch = MidiTools.getNoteNumber(pitch);
    channel.noteOn(midipitch, velocity);
    final Pitch p = pitch;
    final Timer timer = new Timer();
    timer.schedule(new TimerTask() {

        @Override
        public void run() {
            stopSingleNote(p);
            timer.cancel();
        }
    }, duration);
}
Also used : Timer(java.util.Timer) TimerTask(java.util.TimerTask) PitchedInstrument(com.xenoage.zong.core.instrument.PitchedInstrument) Pitch(com.xenoage.zong.core.music.Pitch)

Example 3 with Pitch

use of com.xenoage.zong.core.music.Pitch in project Zong by Xenoage.

the class Test72b method testNotatedPitches.

@Test
public void testNotatedPitches() {
    for (int iStaff : range(expectedNotatedPitches.length)) {
        MP mp = MP.atElement(iStaff, 0, 0, 0);
        Chord chord = getChordAt(score, mp);
        Pitch pitch = chord.getNotes().get(0).getPitch();
        assertEquals("" + mp, expectedNotatedPitches[iStaff], pitch);
    }
}
Also used : MP(com.xenoage.zong.core.position.MP) Pitch(com.xenoage.zong.core.music.Pitch) Chord(com.xenoage.zong.core.music.chord.Chord) Test(org.junit.Test)

Example 4 with Pitch

use of com.xenoage.zong.core.music.Pitch in project Zong by Xenoage.

the class Test72c method testNotatedPitches.

@Test
public void testNotatedPitches() {
    for (int iMeasure : range(expectedTransposes.length)) {
        MP mp = MP.atElement(0, iMeasure, 0, 0);
        Chord chord = getChordAt(score, mp);
        Pitch pitch = chord.getNotes().get(0).getPitch();
        assertEquals("" + mp, expectedNotatedPitch, pitch);
    }
}
Also used : MP(com.xenoage.zong.core.position.MP) Pitch(com.xenoage.zong.core.music.Pitch) Chord(com.xenoage.zong.core.music.chord.Chord) Test(org.junit.Test)

Example 5 with Pitch

use of com.xenoage.zong.core.music.Pitch in project Zong by Xenoage.

the class Test72a method testNotatedPitches.

@Test
public void testNotatedPitches() {
    for (int iStaff : range(3)) {
        for (int iMeasure : range(2)) {
            for (int iElement : range(4)) {
                MP mp = MP.atElement(iStaff, iMeasure, 0, iElement);
                Chord chord = getChordAt(score, mp);
                Pitch pitch = chord.getNotes().get(0).getPitch();
                assertEquals("" + mp, expectedNotatedPitches[iStaff][iMeasure * 4 + iElement], pitch);
            }
        }
    }
}
Also used : MP(com.xenoage.zong.core.position.MP) Pitch(com.xenoage.zong.core.music.Pitch) Chord(com.xenoage.zong.core.music.chord.Chord) Test(org.junit.Test)

Aggregations

Pitch (com.xenoage.zong.core.music.Pitch)24 Chord (com.xenoage.zong.core.music.chord.Chord)12 Test (org.junit.Test)11 MP (com.xenoage.zong.core.position.MP)4 MxlPitch (com.xenoage.zong.musicxml.types.MxlPitch)4 MxlFullNote (com.xenoage.zong.musicxml.types.groups.MxlFullNote)4 Staff (com.xenoage.zong.core.music.Staff)3 Note (com.xenoage.zong.core.music.chord.Note)3 Rest (com.xenoage.zong.core.music.rest.Rest)3 Score (com.xenoage.zong.core.Score)2 Measure (com.xenoage.zong.core.music.Measure)2 Voice (com.xenoage.zong.core.music.Voice)2 VoiceElement (com.xenoage.zong.core.music.VoiceElement)2 Grace (com.xenoage.zong.core.music.chord.Grace)2 TimeSignature (com.xenoage.zong.core.music.time.TimeSignature)2 Cursor (com.xenoage.zong.io.selection.Cursor)2 MxlNote (com.xenoage.zong.musicxml.types.MxlNote)2 MxlCueNote (com.xenoage.zong.musicxml.types.choice.MxlCueNote)2 MxlGraceNote (com.xenoage.zong.musicxml.types.choice.MxlGraceNote)2 MxlMusicDataContent (com.xenoage.zong.musicxml.types.choice.MxlMusicDataContent)2