Skip to content

Commit

Permalink
add new MetaModule options
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewryanscott committed Nov 25, 2024
1 parent 7895237 commit ee679d2
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 3 deletions.
12 changes: 12 additions & 0 deletions specs/fileformat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1925,6 +1925,18 @@ module_types:
bit: 2
size: 1
default: false
- ignore_eff_31_after_last_note_off:
number: 0x79
byte: 4
bit: 3
size: 1
default: false
- jump_to_rl_pattern_after_last_note_off:
number: 0x78
byte: 4
bit: 4
size: 1
default: false
chunks:
- name: mappings
type: MetaModuleMappings
Expand Down
16 changes: 16 additions & 0 deletions src/python/rv/modules/base/metamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,19 @@ class PlayPatterns(IntEnum):
size=1,
default=False,
)
ignore_eff_31_after_last_note_off = Option(
name="ignore_eff_31_after_last_note_off",
number=121,
byte=4,
bit=3,
size=1,
default=False,
)
jump_to_rl_pattern_after_last_note_off = Option(
name="jump_to_rl_pattern_after_last_note_off",
number=120,
byte=4,
bit=4,
size=1,
default=False,
)
30 changes: 29 additions & 1 deletion src/ts/modtypes/metaModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export namespace MetaModule {
receiveNotesFromKeyboard: boolean
doNotReceiveNotesFromKeyboard: boolean
autoBpmTpl: boolean
ignoreEff_31AfterLastNoteOff: boolean
jumpToRlPatternAfterLastNoteOff: boolean
}
class MetaModuleOptions implements Options {
constructor(readonly optionValues: MetaModuleOptionValues) {}
Expand Down Expand Up @@ -108,6 +110,22 @@ export namespace MetaModule {
set autoBpmTpl(newValue: boolean) {
this.optionValues.autoBpmTpl = newValue
}
// noinspection JSUnusedGlobalSymbols
get ignoreEff_31AfterLastNoteOff(): boolean {
return this.optionValues.ignoreEff_31AfterLastNoteOff
}
// noinspection JSUnusedGlobalSymbols
set ignoreEff_31AfterLastNoteOff(newValue: boolean) {
this.optionValues.ignoreEff_31AfterLastNoteOff = newValue
}
// noinspection JSUnusedGlobalSymbols
get jumpToRlPatternAfterLastNoteOff(): boolean {
return this.optionValues.jumpToRlPatternAfterLastNoteOff
}
// noinspection JSUnusedGlobalSymbols
set jumpToRlPatternAfterLastNoteOff(newValue: boolean) {
this.optionValues.jumpToRlPatternAfterLastNoteOff = newValue
}
}
export class Module extends ModuleBase implements ModuleType {
name = "MetaModule"
Expand Down Expand Up @@ -158,6 +176,8 @@ export namespace MetaModule {
receiveNotesFromKeyboard: false,
doNotReceiveNotesFromKeyboard: false,
autoBpmTpl: false,
ignoreEff_31AfterLastNoteOff: false,
jumpToRlPatternAfterLastNoteOff: false,
}
readonly options: MetaModuleOptions = new MetaModuleOptions(this.optionValues)
readonly o = this.options
Expand Down Expand Up @@ -239,7 +259,7 @@ export namespace MetaModule {
return a
}
rawOptionBytes(): Uint8Array {
const bytes = new Uint8Array(7)
const bytes = new Uint8Array(9)
const { optionValues: ov } = this
bytes[0] |= (Number(ov.userDefinedControllers) & (2 ** 4 - 1)) << 0
bytes[1] |= (Number(ov.arpeggiator) & (2 ** 1 - 1)) << 0
Expand All @@ -248,6 +268,8 @@ export namespace MetaModule {
bytes[4] |= (Number(ov.receiveNotesFromKeyboard) & (2 ** 1 - 1)) << 0
bytes[4] |= (Number(ov.doNotReceiveNotesFromKeyboard) & (2 ** 1 - 1)) << 1
bytes[4] |= (Number(ov.autoBpmTpl) & (2 ** 1 - 1)) << 2
bytes[4] |= (Number(ov.ignoreEff_31AfterLastNoteOff) & (2 ** 1 - 1)) << 3
bytes[4] |= (Number(ov.jumpToRlPatternAfterLastNoteOff) & (2 ** 1 - 1)) << 4
return bytes
}
setOptions(dataChunks: ModuleDataChunks) {
Expand All @@ -272,6 +294,12 @@ export namespace MetaModule {
(chdt[4] >> 1) & (2 ** 1 - 1)
)
this.optionValues.autoBpmTpl = Boolean((chdt[4] >> 2) & (2 ** 1 - 1))
this.optionValues.ignoreEff_31AfterLastNoteOff = Boolean(
(chdt[4] >> 3) & (2 ** 1 - 1)
)
this.optionValues.jumpToRlPatternAfterLastNoteOff = Boolean(
(chdt[4] >> 4) & (2 ** 1 - 1)
)
}
}
}
Expand Down
Binary file added tests/files/metamodule-option-78.sunsynth
Binary file not shown.
Binary file added tests/files/metamodule-option-79.sunsynth
Binary file not shown.
File renamed without changes.
14 changes: 12 additions & 2 deletions tests/python/readwrite/synth/test_metamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ def test_metamodule(read_write_read_synth):
assert isinstance(project.modules[1], m.AnalogGenerator)


def test_metamodule_auto_bpm_tpl(read_write_read_synth):
mod: m.MetaModule = read_write_read_synth("metamodule-auto-bpm-tpl").module
def test_metamodule_7a(read_write_read_synth):
mod: m.MetaModule = read_write_read_synth("metamodule-option-7a").module
assert mod.auto_bpm_tpl is True


def test_metamodule_79(read_write_read_synth):
mod: m.MetaModule = read_write_read_synth("metamodule-option-79").module
assert mod.ignore_eff_31_after_last_note_off is True


def test_metamodule_78(read_write_read_synth):
mod: m.MetaModule = read_write_read_synth("metamodule-option-78").module
assert mod.jump_to_rl_pattern_after_last_note_off is True
51 changes: 51 additions & 0 deletions tests/ts/readwrite/metamodule.sunsynth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,54 @@ const expectedControllerNames = [
undefined,
undefined,
]

describe("Reading the metamodule-option-7a file", () => {
const filePath = "tests/files/metamodule-option-7a.sunsynth"
let synth: Synth
beforeAll(() => {
// read, write, read
const f = readFileSync(filePath)
synth = readSunVoxFile(fromIffBuffer(f)) as Synth
const f2 = toIffBuffer(objectChunks(synth))
synth = readSunVoxFile(fromIffBuffer(f2)) as Synth
})
test("has correct properties, controllers, and options", () => {
const mod = synth.module as m.MetaModule.Module
const { o } = mod
expect(o.autoBpmTpl).toBeTruthy()
})
})

describe("Reading the metamodule-option-79 file", () => {
const filePath = "tests/files/metamodule-option-79.sunsynth"
let synth: Synth
beforeAll(() => {
// read, write, read
const f = readFileSync(filePath)
synth = readSunVoxFile(fromIffBuffer(f)) as Synth
const f2 = toIffBuffer(objectChunks(synth))
synth = readSunVoxFile(fromIffBuffer(f2)) as Synth
})
test("has correct properties, controllers, and options", () => {
const mod = synth.module as m.MetaModule.Module
const { o } = mod
expect(o.ignoreEff_31AfterLastNoteOff).toBeTruthy()
})
})

describe("Reading the metamodule-option-78 file", () => {
const filePath = "tests/files/metamodule-option-78.sunsynth"
let synth: Synth
beforeAll(() => {
// read, write, read
const f = readFileSync(filePath)
synth = readSunVoxFile(fromIffBuffer(f)) as Synth
const f2 = toIffBuffer(objectChunks(synth))
synth = readSunVoxFile(fromIffBuffer(f2)) as Synth
})
test("has correct properties, controllers, and options", () => {
const mod = synth.module as m.MetaModule.Module
const { o } = mod
expect(o.jumpToRlPatternAfterLastNoteOff).toBeTruthy()
})
})

0 comments on commit ee679d2

Please sign in to comment.