Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
### TODO

## Things today (13/05/2025)

- [ ] Fix all dialogue boxes
- [x] Rename temp to pick
- [ ] Pattern on top of screen to swap out in the pattern viewer - May include passing in song and pattern index instead of just passing in a pattern
- [ ] Implement copy-paste
- [ ] Arrow showing which pattern is being played currently
- [ ] Ensure playing full song works on main, aka, test on microbit
- [ ] Fix the way settings work on main

## Specs of song screen

- [ ] Should be able to open up with a song
- [ ] Song has a number of patterns, patterns are shown
- [ ] Click on a pattern and should either be able to replace it or edit it
- [ ] Replace gives the option to pick a pattern from all our patterns or to let us make a new one
- [ ] Edit brings up patternComposer screen letting us edit it
- [ ] Click on an empty pattern, brings up choice to use existing or new, existing brings up same page as replace for selection
- [ ] Need a way to naturally scroll through if we have a lot of patterns
- [ ] Limit song size to 12, that would be 3 minutes at 220bpm if all were full
- [ ] Consider limit on number of patterns, max 12 we can swap out? Or maybe 24, would then need a natural way to scroll through
- [ ] Copy-paste, select copying a channel or copying an entire pattern into a new one, since channels are now 64 rows i don't think I need further copying, maybe add a way to copy a certain amount but would take more [If I have the man hours I'll do it]
- [ ] Need to add options to option buttons for removing patterns or sequence, on the boxes for seq but elsewhere on the screen for pattern..?

## Things by this week

Console.log over serial

- [ ] More than 1 bank of track data important one, can have them playing after eachother
- [ ] Want a nice strong evaluation, start thinking about that now
- [ ] Intuitiveness, when selecting a note, A to come out of it and B to reset the note to "-"? Or A to reset, B to come out of it
- [ ] Pattern at the top of the screen so you can swap straight in the patterns editor
- [ ] Change size of invisible buttons on confirmation pages

## Bugs

Expand Down
20 changes: 20 additions & 0 deletions assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace micromusic {
if (name == "largeDisk") return icondb.largeDisk

if (name == "volume") return icondb.volumeLogo
if (name == "invisiblePatternButton")
return icondb.invisiblePatternButton

if (name == "green_tick_2") return icondb.green_tick_transparent

Expand Down Expand Up @@ -151,6 +153,24 @@ namespace icondb {
//------------------------
// "ICONLESS" BUTTON ICONS
//------------------------
export const invisiblePatternButton = bmp`
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
`

export const invisibleButtonPlaceholder = bmp`
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
Expand Down
7 changes: 6 additions & 1 deletion channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ namespace micromusic {
private _notes: string[]
private _octaves: number[]
private _sample: Sample
private _id: number

constructor() {
constructor(id: number) {
this._notes = []
this._octaves = []

Expand All @@ -17,6 +18,10 @@ namespace micromusic {
this._sample = new Sample("ResBass")
}

public get id() {
return this._id
}

public get notes() {
return this._notes
}
Expand Down
12 changes: 2 additions & 10 deletions home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ namespace micromusic {
private liveDataBtn: Button
private recordDataBtn: Button
private distributedLoggingBtn: Button
private volume: Setting
// private viewBtn: Button

constructor(app: AppInterface) {
super(app)
this.volume = new Setting(100)
}

/* override */ startup() {
Expand All @@ -36,7 +33,7 @@ namespace micromusic {
onClick: () => {
this.app.popScene()
this.app.pushScene(
PatternScreen.getInstance(this.app)
SongComposerScreen.getInstance(this.app)
)
},
})),
Expand All @@ -59,11 +56,7 @@ namespace micromusic {
onClick: () => {
this.app.popScene()
this.app.pushScene(
SettingsScreen.getInstance(
this.app,
this,
this.volume
)
SettingsScreen.getInstance(this, this.app)
)
},
})),
Expand Down Expand Up @@ -133,7 +126,6 @@ namespace micromusic {
this.liveDataBtn.draw()
this.recordDataBtn.draw()
this.distributedLoggingBtn.draw()
// this.viewBtn.draw()

this.drawVersion()
super.draw()
Expand Down
21 changes: 16 additions & 5 deletions pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@ namespace micromusic {

export class Pattern {
private _channels: Channel[]
private _id: number

constructor() {
constructor(id: number) {
this._channels = [
new Channel(),
new Channel(),
new Channel(),
new Channel(),
new Channel(0),
new Channel(1),
new Channel(2),
new Channel(3),
]

this._id = id
}

public get id() {
return this._id
}

public setChannel(channel: Channel, index: number) {
Expand All @@ -24,5 +31,9 @@ namespace micromusic {
public getChannel(index: number) {
return this._channels[index]
}

public playAsync() {
// starts playing on all channels, each one has their own control.inbackground?
}
}
}
71 changes: 25 additions & 46 deletions patternComposer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace micromusic {

const NUM_TRACKS = 4
const NUM_VISIBLE_STEPS = 8
const TOTAL_BANKS = 4
const LEFT_TRACK_INDEX = 0
const RIGHT_TRACK_INDEX = 1
const NOTES = [
Expand Down Expand Up @@ -48,7 +47,6 @@ namespace micromusic {
private static instance: PatternScreen | null = null
private currentStep: number
private currentTrack: number
// private trackData: Note[][][]
private controlBtns: Button[]
private sampleSelectBtn: Button
private noteSelectBtn: Button
Expand All @@ -66,14 +64,13 @@ namespace micromusic {
private cursorVisible: boolean
private playedNote: number
private hasClickedBack: boolean
private currentBank: number

private pattern: Pattern
private channels: Channel[]

private constructor(
app: AppInterface,
pattern?: Pattern,
pattern: Pattern,
volume?: Setting,
bpm?: Setting
) {
Expand All @@ -97,11 +94,7 @@ namespace micromusic {
this.bpm = new Setting(120)
}

if (pattern) {
this.pattern = pattern
} else {
this.pattern = new Pattern()
}
this.pattern = pattern

this.selectedTrackPos = 0
this.currentStep = 0
Expand All @@ -115,23 +108,28 @@ namespace micromusic {
this.isSelectingSample = false
this.playedNote = 0
this.hasClickedBack = false
this.currentBank = 0
}

public static getInstance(
pattern: Pattern,
app?: AppInterface,
volume?: Setting,
bpm?: Setting
) {
if (!PatternScreen.instance) {
if (app === undefined) {
if (app === undefined || pattern === undefined) {
console.error(
"SoundTrackerScreen singleton not initialized. Call with parameters first."
"PatternScreen singleton not initialized. Call with parameters first."
)
}
PatternScreen.instance = new PatternScreen(app)
PatternScreen.instance = new PatternScreen(app, pattern)
}

if (!pattern) {
console.error("Pattern required")
}
PatternScreen.instance.setPattern(pattern)

return PatternScreen.instance
}

Expand Down Expand Up @@ -188,12 +186,7 @@ namespace micromusic {
this.isPlaying = false
this.app.popScene()
this.app.pushScene(
SettingsScreen.getInstance(
this.app,
this,
this.volume,
this.bpm
)
SettingsScreen.getInstance(this, this.app)
)
},
}),
Expand Down Expand Up @@ -233,6 +226,10 @@ namespace micromusic {
this.resetControllerEvents()
}

private setPattern(pattern: Pattern) {
this.pattern = pattern
}

private backConfirmation() {
if (this.isPlaying) {
this.resetControllerEvents()
Expand All @@ -249,8 +246,9 @@ namespace micromusic {
x: -22,
y: 18,
onClick: () => {
this.hasClickedBack = false
this.app.popScene()
this.app.pushScene(new Home(this.app))
this.app.pushScene(SongComposerScreen.getInstance())
},
}),
new Button({
Expand All @@ -262,8 +260,8 @@ namespace micromusic {
onClick: () => {
this.hasClickedBack = false
this.resetNavigator()
this.moveCursor(CursorDir.Up)
this.moveCursor(CursorDir.Down)
this.moveCursor(CursorDir.Left)
this.moveCursor(CursorDir.Right)
},
}),
],
Expand Down Expand Up @@ -430,9 +428,10 @@ namespace micromusic {
if (this.hasClickedBack) {
Screen.fillRect(-57, -37, 120, 80, 0)
Screen.fillRect(-60, -40, 120, 80, 0x6)
this.drawText(-36, -30, "Return Home?")
Screen.print("Any unsaved work", -48, -20, 0x2)
Screen.print("will be lost", -38, -10, 0x2)
this.drawText(-36, -15, "Return Home?")
this.cursor.setOutlineColour(0x2)
// Screen.print("Any unsaved work", -48, -20, 0x2)
// Screen.print("will be lost", -38, -10, 0x2)
this.drawText(-30, 15, "Yes")
this.drawText(15, 15, "No")
this.cursor.draw()
Expand All @@ -446,6 +445,7 @@ namespace micromusic {
this.drawSamples()
this.drawGrid()
this.drawBankSelector()
this.cursor.setOutlineColour(0x9)
super.draw()
}

Expand Down Expand Up @@ -534,27 +534,6 @@ namespace micromusic {
}
}

private switchToBank(bankIndex: number) {
if (bankIndex >= 0 && bankIndex < TOTAL_BANKS) {
// If playing, stop before switching banks
if (this.isPlaying) {
this.pause()
}

this.currentBank = bankIndex

// Reset current step when switching banks
this.currentStep = 0

// Redraw the screen
this.draw()
}
}

private nextBank() {
this.switchToBank((this.currentBank + 1) % TOTAL_BANKS)
}

private drawText(
x: number,
y: number,
Expand Down
3 changes: 2 additions & 1 deletion pxt.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"patternComposer.ts",
"song.ts",
"pattern.ts",
"channel.ts"
"channel.ts",
"settings.ts"
],
"testFiles": [],
"targetVersions": {
Expand Down
2 changes: 1 addition & 1 deletion sampleSelectionScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ namespace micromusic {
app,
function () {
this.app.popScene()
this.previousScene.navigator = new GridNavigator()
this.app.pushScene(this.previousScene)
},
new GridNavigator()
Expand Down Expand Up @@ -213,6 +212,7 @@ namespace micromusic {
Screen.print("Select Sample", -40, -50, 0x1)

this.cursor.draw()
super.draw()
}
}
}
22 changes: 22 additions & 0 deletions settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace micromusic {
export class Settings {
private static _volume: Setting = new Setting(100)
private static _bpm: Setting = new Setting(120)

public static get volume(): Setting {
return this._volume
}

public static setVolume(vol: number) {
this._volume.value = vol
}

public static get bpm(): Setting {
return this._bpm
}

public static setBpm(bpm: number) {
this._bpm.value = bpm
}
}
}
Loading