*/ private static function events(Music $m): array { return (new \ReflectionProperty(Music::class, 'events'))->getValue($m); } public function testAMusSongIsReadAsItsNotesInTime(): void { $m = self::music(); $m->play('D_TEST', self::mus()); self::assertSame([ [0.0, 0xC0, 0, 19, 0], [0.0, 0x90, 0, 60, 100], [0.5, 0x80, 0, 60, 0], [0.5, 0x90, 9, 36, 127], // channel 15 of MUS is MIDI's percussion channel; its last volume: 127 at first ], self::events($m)); self::assertEqualsWithDelta(1.0, (new \ReflectionProperty(Music::class, 'length'))->getValue($m), 1e-9); } public function testAMusSongIsHeard(): void { $m = self::music(); $m->play('D_TEST', self::mus()); self::assertNotSame(str_repeat("\0", 4096), $m->render(2048), 'the synthesizer plays the MUS notes'); } public function testTheMusPitchWheelIsCentredAt128(): void { $m = self::music(); $score = "\x20\x80" . "\x20\xFF" . "\x60"; // pitch wheel 128 (centre), then 255 (up), then the end $m->play('D_BEND', "MUS\x1A" . pack('vvvvvv', strlen($score), 16, 1, 0, 0, 0) . $score); self::assertSame([[0.0, 0xE0, 0, 0, 64], [0.0, 0xE0, 0, 64, 127]], self::events($m)); } }