Initial commit: Sizzletracker Android music tracker
A retro, grid-based music tracker for Android (Kotlin + Jetpack Compose, single Activity) with four equally-capable input methods (touch, keyboard, gamepad, MIDI) and four tabs: tracker, mixer, toolbox, settings. Highlights: - Tracker: Canvas-drawn 4-track pattern grid over an 8-lane arrangement roll, with a glyph cache and draw-phase state reads so the playhead and edits redraw without per-frame recomposition. - Audio: sample-accurate sequencer feeding a shared AudioEngine, driven by either a Kotlin AudioTrack loop or native Oboe/AAudio via JNI (16 KB-aligned native libs). media3 MediaSession for lock-screen/headset transport. - Toolbox: 16 instrument/effect slots with a 2-octave audition keyboard; single-tap select, double-tap edit, long-press clear. - Note entry: long-press cell popups (piano keyboard / value steppers) plus keyboard/gamepad stepping that resumes from the last note/channel entered. Velocity capped at 0x7F, channel at 16. - Selection/clipboard (cut/copy/paste/delete) and .sng import/export compatible with the reference desktop tool. - A `profile` build type (non-debuggable, debug-signed) for realistic on-device performance testing. - Developer handover documentation under docs/. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
package com.reactorcoremeltdown.sizzletracker.io
|
||||
|
||||
import com.reactorcoremeltdown.sizzletracker.model.Arrangement
|
||||
import com.reactorcoremeltdown.sizzletracker.model.Pitch
|
||||
import com.reactorcoremeltdown.sizzletracker.model.Project
|
||||
import com.reactorcoremeltdown.sizzletracker.model.TimeSignature
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
/** Verifies the `.sng` reader/writer against the reference desktop format. */
|
||||
class SngFormatTest {
|
||||
|
||||
private val reference = """
|
||||
version 1
|
||||
bpm 120
|
||||
sig 4 4
|
||||
|
||||
block A 16 4
|
||||
roll ####
|
||||
track T1 0
|
||||
0 C-4 64 01
|
||||
4 E-4 .. ..
|
||||
8 OFF .. ..
|
||||
endblock
|
||||
""".trimIndent()
|
||||
|
||||
@Test
|
||||
fun parsesReferenceExample() {
|
||||
val p = SngFormat.import(reference)
|
||||
|
||||
assertEquals(120f, p.tempoBpm, 0.001f)
|
||||
assertEquals(TimeSignature.FOUR_FOUR, p.timeSignature)
|
||||
|
||||
val block = p.patterns[0]
|
||||
assertEquals("A", block.name)
|
||||
assertEquals(16, block.length)
|
||||
|
||||
val c0 = block.cell(0, 0)
|
||||
assertEquals(Pitch.parse("C-4"), c0.note)
|
||||
assertEquals(0x64, c0.velocity) // velocity is hexadecimal
|
||||
assertEquals(1, c0.channel)
|
||||
|
||||
val c4 = block.cell(0, 4)
|
||||
assertEquals(Pitch.parse("E-4"), c4.note)
|
||||
assertEquals(0x7F, c4.velocity) // ".." -> default (full MIDI velocity)
|
||||
assertEquals(1, c4.channel) // ".." -> inherit track channel (0 -> 1)
|
||||
|
||||
assertTrue(block.cell(0, 8).isNoteOff)
|
||||
|
||||
// roll "####" enables block 0 on beats 0..3 of its own lane.
|
||||
for (beat in 0..3) assertNotEquals(Arrangement.EMPTY, p.arrangement.patternAt(0, beat))
|
||||
assertEquals(Arrangement.EMPTY, p.arrangement.patternAt(0, 4))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun roundTripsNotesAndRoll() {
|
||||
val p = Project()
|
||||
p.tempoBpm = 140f
|
||||
p.timeSignature = TimeSignature.FIVE_FOUR
|
||||
p.patterns[0].cell(0, 0).apply { note = 60; velocity = 0x40; channel = 3 }
|
||||
p.patterns[0].cell(1, 5).apply { note = 67; velocity = 0x7F; channel = 2 }
|
||||
p.arrangement.set(0, 0, 0)
|
||||
p.arrangement.set(0, 1, 0)
|
||||
|
||||
val restored = SngFormat.import(SngFormat.export(p))
|
||||
|
||||
assertEquals(140f, restored.tempoBpm, 0.001f)
|
||||
assertEquals(TimeSignature.FIVE_FOUR, restored.timeSignature)
|
||||
restored.patterns[0].cell(0, 0).let {
|
||||
assertEquals(60, it.note); assertEquals(0x40, it.velocity); assertEquals(3, it.channel)
|
||||
}
|
||||
restored.patterns[0].cell(1, 5).let {
|
||||
assertEquals(67, it.note); assertEquals(0x7F, it.velocity); assertEquals(2, it.channel)
|
||||
}
|
||||
assertNotEquals(Arrangement.EMPTY, restored.arrangement.patternAt(0, 0))
|
||||
assertNotEquals(Arrangement.EMPTY, restored.arrangement.patternAt(0, 1))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user