From 32587e9516f128a39000c4f9d99723d8235f80f0 Mon Sep 17 00:00:00 2001 From: Casey Mulcahy Date: Mon, 29 Apr 2024 11:30:12 -0400 Subject: [PATCH 1/3] Build Linux version with Go 1.22 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 344bcdf..12685e7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.21' + go-version: '1.22' - name: Install dependencies run: sudo apt install rename lib{asound2,x11,xext,xcursor,xinerama,xi,xrandr,xss,xxf86vm,sdl2,sdl2-ttf}-dev From fa8cb8bcf94c01bfb4655a39a3a4054c358d50a7 Mon Sep 17 00:00:00 2001 From: Casey Mulcahy Date: Tue, 13 Aug 2024 09:18:43 -0400 Subject: [PATCH 2/3] Add MidiInputChannels setting --- docs/config.md | 5 +++++ faunatone/config/settings.csv | 1 + faunatone/keymap.go | 8 ++++++-- faunatone/main.go | 19 +++++++++++++++++-- faunatone/settings.go | 1 + 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/docs/config.md b/docs/config.md index 82d9bb8..4de66b5 100644 --- a/docs/config.md +++ b/docs/config.md @@ -41,6 +41,11 @@ folder. **MidiInPortNumber** - The index of the MIDI input port used. -1 means none. +**MidiInputChannels** - How to interpret input from different MIDI channels. +`ignore` means that all input channels are identical. `octaves` means that +channel 1 is mapped to the base octave, channel 2 is mapped an octave higher, +and so on. + **MidiOutPortNumber** - The index of the MIDI output port used. -1 means none. Can use multiple port numbers, separated by spaces; in this case, the first port is the default. diff --git a/faunatone/config/settings.csv b/faunatone/config/settings.csv index 415514d..c79f49f 100644 --- a/faunatone/config/settings.csv +++ b/faunatone/config/settings.csv @@ -10,6 +10,7 @@ Font, RobotoMono-Regular.ttf FontSize, 12 MessageDuration, 3 MidiInPortNumber, -1 +MidiInputChannels, ignore MidiOutPortNumber, 0 OffDivisionAlpha, 64 PitchBendSemitones, 24 diff --git a/faunatone/keymap.go b/faunatone/keymap.go index 3b4bde7..1409a07 100644 --- a/faunatone/keymap.go +++ b/faunatone/keymap.go @@ -532,10 +532,14 @@ func (k *keymap) keyboardEvent(e *sdl.KeyboardEvent, pe *patternEditor, p *playe // respond to midi input events func (k *keymap) midiEvent(msg []byte, pe *patternEditor, p *player, keyjazz bool) { + var octaveOffset byte + if midiChannelBehavior == midiChannelOctaves { + octaveOffset = msg[0] & 0xf + } if msg[0]&0xf0 == 0x90 && msg[2] > 0 { // note on var te *trackEvent if sdl.GetModState()&sdl.KMOD_SHIFT == 0 { - pitch := k.adjustPerKeySig(k.midimap[msg[1]]) + pe.refPitch + pitch := k.adjustPerKeySig(k.midimap[msg[1]]) + pe.refPitch + float64(octaveOffset)*12 te = newTrackEvent(&trackEvent{ Type: noteOnEvent, FloatData: pitch, @@ -544,7 +548,7 @@ func (k *keymap) midiEvent(msg []byte, pe *patternEditor, p *player, keyjazz boo } else { te = newTrackEvent(&trackEvent{ Type: drumNoteOnEvent, - ByteData1: msg[1], + ByteData1: msg[1] + octaveOffset*12, ByteData2: msg[2], }, k) } diff --git a/faunatone/main.go b/faunatone/main.go index 4c71fbf..e3d098d 100644 --- a/faunatone/main.go +++ b/faunatone/main.go @@ -32,6 +32,13 @@ const ( errorLogFile = "error.txt" ) +const ( + midiChannelIgnore int = iota + midiChannelOctaves +) + +var midiChannelBehavior int + //go:embed config/* var embedFS embed.FS @@ -62,6 +69,8 @@ func must(err error) { } func main() { + dia := &dialog{} + settings := loadSettings(func(s string) { println(s) }) bendSemitones = settings.PitchBendSemitones setColorArray(colorBeatArray, settings.ColorBeat) @@ -71,10 +80,16 @@ func main() { setColorSDL(&colorFg, settings.ColorFg) setColorArray(colorPlayPosArray, settings.ColorPlayPos) setColorArray(colorSelectArray, settings.ColorSelect) + switch settings.MidiInputChannels { + case "ignore": + midiChannelBehavior = midiChannelIgnore + case "octaves": + midiChannelBehavior = midiChannelOctaves + default: + dia.message(fmt.Sprintf("Invalid MidiInputChannels setting: %q", settings.MidiInputChannels)) + } padding = int32(settings.FontSize) / 2 - dia := &dialog{} - drv, err := driver.New() must(err) defer drv.Close() diff --git a/faunatone/settings.go b/faunatone/settings.go index 6ade755..4c1129d 100644 --- a/faunatone/settings.go +++ b/faunatone/settings.go @@ -24,6 +24,7 @@ type settings struct { FontSize int MessageDuration int MidiInPortNumber int + MidiInputChannels string MidiOutPortNumber string OffDivisionAlpha int PitchBendSemitones int From 28589fd64df6b2f6d0a8c4c3d33ed6b30be82a95 Mon Sep 17 00:00:00 2001 From: Casey Mulcahy Date: Tue, 13 Aug 2024 09:20:01 -0400 Subject: [PATCH 3/3] Update version for 0.8.0 --- faunatone/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faunatone/main.go b/faunatone/main.go index c91b725..4ec30c6 100644 --- a/faunatone/main.go +++ b/faunatone/main.go @@ -22,7 +22,7 @@ import ( const ( appName = "Faunatone" - appVersion = "v0.7.0" + appVersion = "v0.8.0" fileExt = ".faun" defaultFps = 60 configPath = "config"