### ----------------------------------------------------
### -- MIDI::Make
### -- Licenses: MIT
### -- Authors: Pierre-Emmanuel Lévesque <pierre.e.levesque@gmail.com>
### -- File: t/all.rakutest
### ----------------------------------------------------
### -- Chunk 2 of 2
72 6B 00 00 00 08
     00 E0 00 00
     00 FF 2F 00',
);

test('t37',
    'Track: pitch-bend => highest',
    {
        my \t = Track.new;
	    t.pitch-bend: 16383;
	    t;
    },
    '4D 54 72 6B 00 00 00 08
     00 E0 7F 7F
     00 FF 2F 00',
);

test('t38',
    'Track: pitch-bend => 10000',
    {
        my \t = Track.new;
	    t.pitch-bend: 10000;
	    t;
    },
    '4D 54 72 6B 00 00 00 08
     00 E0 10 4E
     00 FF 2F 00',
);

test('t39',
    'Track: sysex',
    {
        my \t = Track.new;
	    t.sysex: <0A 29 1E>;
	    t;
    },
    '4D 54 72 6B 00 00 00 0A
     00 F0 0A 29 1E F7
     00 FF 2F 00',
);

test('t40',
    'Track: add-bytes',
    {
        my \t = Track.new;
	    t.add-bytes: <00 F0 0A 29 1E F7>;
	    t;
    },
    '4D 54 72 6B 00 00 00 0A
     00 F0 0A 29 1E F7
     00 FF 2F 00',
);

t 't41' => {
    is(
        do {
            my \t = Track.new;
            t.delta-time: 100;
            t.copyright: 'c 2022 anonymous';
            t.name: 'melody';
            t.render;
            t.delta-time;
        },
        100,
        'Track: delta-time remains intact after render'
    );
}

# --------------------------------------------------------------------
# Everything

test('e1',
    'Everything',
    {
        my \t = Track.new;
        t.copyright:      'c 2022 anonymous';
        t.name:           'melody';
        t.instrument:     'piano';
        t.controller:     8, 100;
        t.program-name:   'electric piano';
        t.port:           'MIDI Out 1';
        t.channel:        1;
        t.program-change: 100;
        t.aftertouch:     100;
        t.pitch-bend:     0;
        t.marker:                 'section I';
        t.text:           'Lorem ipsum dolor sit amet.';
        t.key-signature:  2♭, minor;
        t.tempo:          ♩80;
        t.time-signature: 3\2;
        t.aftertouch:     100, 53;
        t.note-on:        60;
        t.lyric:          'one';
        t.delta-time:         128;
        t.note-off:       60;
        t.cue:            'door slam';
        t.velocity-on:    80;
        t.velocity-off:   10;
        t.note-on:        72;
        t.lyric:          'two';
        t.delta-time:         128;
        t.note-off:       72;
        t.sysex:          <0A 29 1E>;
        t.add-bytes:      <00 F0 0A 29 1E F7>;

        my \s = Song.new;
        s.format: 2;
        s.time-division: 'frame';
        s.PPQ: 96; # Should be ignored with time-division == frame.
        s.FPS: 25;
        s.PPF: 8;
        s.add-track(t.render);
        s;
    },
    '4D 54 68 64 00 00 00 06
     00 02 00 01 E7 08
     4D 54 72 6B 00 00 00 D7
     00 FF 02 10 63 20 32 30 32 32 20 61 6E 6F 6E 79 6D 6F 75 73
     00 FF 03 06 6D 65 6C 6F 64 79
     00 FF 04 05 70 69 61 6E 6F
     00 B0 08 64
     00 FF 08 0E 65 6C 65 63 74 72 69 63 20 70 69 61 6E 6F
     00 FF 09 0A 4D 49 44 49 20 4F 75 74 20 31
     00 C1 64
     00 D1 64
     00 E1 00 00
     00 FF 06 09 73 65 63 74 69 6F 6E 20 49
     00 FF 01 1B 4C 6F 72 65 6D 20 69 70 73 75 6D 20 64 6F 6C 6F 72 20
      73 69 74 20 61 6D 65 74 2E
     00 FF 59 02 FE 01
     00 FF 51 03 0B 71 B0
     00 FF 58 04 03 01 18 08
     00 A1 35 64
     00 91 3C 7F
     00 FF 05 03 6F 6E 65 81
     00 81 3C 00
     00 FF 07 09 64 6F 6F 72 20 73 6C 61 6D
     00 91 48 50
     00 FF 05 03 74 77 6F 81
     00 81 48 0A
     00 F0 0A 29 1E F7
     00 F0 0A 29 1E F7
     00 FF 2F 00',
);

done-testing;


