Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small additions and new patches! #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions tracker/gioui/instrument_editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ func NewInstrumentEditor(model *tracker.Model) *InstrumentEditor {
unitEditor: NewUnitEditor(model),
presetMenuItems: []MenuItem{},
}
model.IterateInstrumentPresets(func(index int, name string) bool {
ret.presetMenuItems = append(ret.presetMenuItems, MenuItem{Text: name, IconBytes: icons.ImageAudiotrack, Doer: model.LoadPreset(index)})
model.IterateInstrumentPresets(func(index int, name string, directory string) bool {
menuText := "[" + directory + "] " + name
if directory == "presets" {
menuText = name
}
ret.presetMenuItems = append(ret.presetMenuItems, MenuItem{Text: menuText, IconBytes: icons.ImageAudiotrack, Doer: model.LoadPreset(index)})
return true
})
for k := range noteMap {
Expand Down
5 changes: 5 additions & 0 deletions tracker/gioui/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ var transparent = color.NRGBA{A: 0}
var primaryColor = color.NRGBA{R: 206, G: 147, B: 216, A: 255}
var secondaryColor = color.NRGBA{R: 128, G: 222, B: 234, A: 255}

var vuMeterAvg = color.NRGBA{R: 000, G: 64, B: 000, A: 255}
var vuMeterAvgClip = color.NRGBA{R: 64, G: 000, B: 000, A: 255}
var vuMeterPeak = color.NRGBA{R: 020, G: 127, B: 0, A: 255}
var vuMeterPeakClip = color.NRGBA{R: 255, G: 000, B: 000, A: 255}

var highEmphasisTextColor = color.NRGBA{R: 222, G: 222, B: 222, A: 222}
var mediumEmphasisTextColor = color.NRGBA{R: 153, G: 153, B: 153, A: 153}
var disabledTextColor = color.NRGBA{R: 255, G: 255, B: 255, A: 97}
Expand Down
19 changes: 18 additions & 1 deletion tracker/gioui/vumeter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,31 @@ func (v VuMeter) Layout(gtx C) D {
gtx.Constraints.Max.Y = gtx.Dp(unit.Dp(12))
height := gtx.Dp(unit.Dp(6))
for j := 0; j < 2; j++ {
peakValue := float32(v.PeakVolume[j]) + v.Range
if peakValue > 0 {
x := int(peakValue/v.Range*float32(gtx.Constraints.Max.X) + 0.5)
if x > gtx.Constraints.Max.X {
x = gtx.Constraints.Max.X
}
color := vuMeterPeak
if peakValue >= v.Range {
color = vuMeterPeakClip
}
paint.FillShape(gtx.Ops, color, clip.Rect(image.Rect(0, 0, x, height)).Op())
}
value := float32(v.AverageVolume[j]) + v.Range
if value > 0 {
x := int(value/v.Range*float32(gtx.Constraints.Max.X) + 0.5)
if x > gtx.Constraints.Max.X {
x = gtx.Constraints.Max.X
}
paint.FillShape(gtx.Ops, mediumEmphasisTextColor, clip.Rect(image.Rect(0, 0, x, height)).Op())
color := vuMeterAvg
if peakValue >= v.Range {
color = vuMeterAvgClip
}
paint.FillShape(gtx.Ops, color, clip.Rect(image.Rect(0, 0, x, height)).Op())
}

valueMax := float32(v.PeakVolume[j]) + v.Range
if valueMax > 0 {
color := white
Expand Down
28 changes: 19 additions & 9 deletions tracker/presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
"sort"
"strings"

"github.com/vsariola/sointu"
"github.com/vsariola/sointu/vm"
Expand All @@ -24,7 +25,7 @@ type (
Name string // sample name
}

InstrumentPresetYieldFunc func(index int, item string) (ok bool)
InstrumentPresetYieldFunc func(index int, item string, directory string) (ok bool)
LoadPreset struct {
Index int
*Model
Expand Down Expand Up @@ -129,7 +130,7 @@ type delayPreset struct {

func (m *Model) IterateInstrumentPresets(yield InstrumentPresetYieldFunc) {
for index, instr := range instrumentPresets {
if !yield(index, instr.Name) {
if !yield(index, instr.instrument.Name, instr.directory) {
return
}
}
Expand All @@ -145,13 +146,18 @@ func (m *Model) LoadPreset(index int) Action {
for m.d.InstrIndex >= len(m.d.Song.Patch) {
m.d.Song.Patch = append(m.d.Song.Patch, defaultInstrument.Copy())
}
m.d.Song.Patch[m.d.InstrIndex] = instrumentPresets[index].Copy()
m.d.Song.Patch[m.d.InstrIndex] = instrumentPresets[index].instrument.Copy()
}, allowed: func() bool {
return true
}}
}

type instrumentPresetsSlice []sointu.Instrument
type instrumentPreset struct {
instrument sointu.Instrument
directory string
}

type instrumentPresetsSlice []instrumentPreset

//go:embed presets/*
var instrumentPresetFS embed.FS
Expand All @@ -171,7 +177,8 @@ func init() {
}
var instr sointu.Instrument
if yaml.Unmarshal(data, &instr) == nil {
instrumentPresets = append(instrumentPresets, instr)
dir := strings.Split(filepath.Dir(path), "\\")
instrumentPresets = append(instrumentPresets, instrumentPreset{instrument: instr, directory: dir[len(dir)-1]})
}
return nil
})
Expand All @@ -190,14 +197,17 @@ func init() {
}
var instr sointu.Instrument
if yaml.Unmarshal(data, &instr) == nil {
instrumentPresets = append(instrumentPresets, instr)
dir := strings.Split(filepath.Dir(path), "\\")
instrumentPresets = append(instrumentPresets, instrumentPreset{instrument: instr, directory: dir[len(dir)-1]})
}
return nil
})
}
sort.Sort(instrumentPresets)
}

func (p instrumentPresetsSlice) Len() int { return len(p) }
func (p instrumentPresetsSlice) Less(i, j int) bool { return p[i].Name < p[j].Name }
func (p instrumentPresetsSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
func (p instrumentPresetsSlice) Len() int { return len(p) }
func (p instrumentPresetsSlice) Less(i, j int) bool {
return p[i].directory < p[j].directory
}
func (p instrumentPresetsSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
69 changes: 69 additions & 0 deletions tracker/presets/BA/House Bass Organ.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: House Bass Organ
numvoices: 2
units:
- type: envelope
id: 207
parameters: {attack: 37, decay: 74, gain: 78, release: 44, stereo: 0, sustain: 49}
- type: oscillator
id: 208
parameters: {color: 64, detune: 54, gain: 128, phase: 0, shape: 64, stereo: 0, transpose: 40, type: 1, unison: 3}
- type: oscillator
id: 213
parameters: {color: 64, detune: 64, gain: 64, phase: 0, shape: 64, stereo: 0, transpose: 71, type: 2, unison: 0}
- type: addp
id: 214
parameters: {stereo: 0}
- type: mulp
id: 209
parameters: {stereo: 0}
- type: filter
id: 218
parameters: {bandpass: 0, frequency: 0, highpass: 0, lowpass: 1, negbandpass: 0, neghighpass: 0, resonance: 128, stereo: 0}
- type: filter
id: 219
parameters: {bandpass: 0, frequency: 66, highpass: 0, lowpass: 1, negbandpass: 0, neghighpass: 0, resonance: 128, stereo: 0}
- type: distort
id: 215
parameters: {drive: 86, stereo: 0}
- type: envelope
id: 221
parameters: {attack: 32, decay: 53, gain: 64, release: 5, stereo: 0, sustain: 0}
- type: noise
id: 222
parameters: {gain: 59, shape: 56, stereo: 0}
- type: mulp
id: 223
parameters: {stereo: 0}
- type: filter
id: 225
parameters: {bandpass: 0, frequency: 71, highpass: 0, lowpass: 1, negbandpass: 1, neghighpass: 0, resonance: 81, stereo: 0}
- type: addp
id: 224
parameters: {stereo: 0}
- type: distort
id: 228
parameters: {drive: 67, stereo: 0}
- type: compressor
id: 229
parameters: {attack: 37, invgain: 87, ratio: 97, release: 65, stereo: 0, threshold: 47}
- type: mulp
id: 230
parameters: {stereo: 0}
- type: pan
id: 211
parameters: {panning: 64, stereo: 0}
- type: outaux
id: 212
parameters: {auxgain: 29, outgain: 69, stereo: 1}
- type: envelope
id: 220
parameters: {attack: 0, decay: 72, gain: 76, release: 45, stereo: 0, sustain: 47}
- type: send
id: 217
parameters: {amount: 128, port: 0, sendpop: 1, stereo: 0, target: 218, unit: 0, voice: 0}
- type: loadnote
id: 226
parameters: {stereo: 0}
- type: send
id: 227
parameters: {amount: 54, port: 0, sendpop: 1, stereo: 0, target: 225, unit: 0, voice: 0}
41 changes: 41 additions & 0 deletions tracker/presets/BA/SuperSaw 1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: SuperSaw 1
numvoices: 3
units:
- type: envelope
id: 1
parameters: {attack: 3, decay: 68, gain: 64, release: 64, stereo: 0, sustain: 64}
- type: oscillator
id: 2
parameters: {color: 128, detune: 100, gain: 128, phase: 0, shape: 64, stereo: 0, transpose: 64, type: 1, unison: 3}
- type: oscillator
id: 10
parameters: {color: 128, detune: 27, gain: 102, lfo: 0, phase: 71, shape: 64, stereo: 0, transpose: 76, type: 1, unison: 3}
- type: addp
id: 11
parameters: {stereo: 0}
- type: mulp
id: 17
parameters: {stereo: 0}
- id: 18
parameters: {}
- type: envelope
id: 12
parameters: {attack: 0, decay: 68, gain: 64, release: 64, stereo: 0, sustain: 64}
- type: oscillator
id: 13
parameters: {color: 128, detune: 31, gain: 128, phase: 78, shape: 64, stereo: 0, transpose: 64, type: 1, unison: 3}
- type: oscillator
id: 14
parameters: {color: 128, detune: 96, gain: 128, lfo: 0, phase: 54, shape: 64, stereo: 0, transpose: 76, type: 1, unison: 3}
- type: addp
id: 15
parameters: {stereo: 0}
- type: mulp
id: 16
parameters: {stereo: 0}
- parameters: {}
- type: pan
parameters: {panning: 70, stereo: 1}
- type: outaux
id: 6
parameters: {auxgain: 0, outgain: 64, stereo: 1}
70 changes: 70 additions & 0 deletions tracker/presets/BA/SuperSaw 2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: SuperSaw 2
numvoices: 4
units:
- type: envelope
id: 1
parameters: {attack: 18, decay: 70, gain: 64, release: 64, stereo: 0, sustain: 64}
- type: oscillator
id: 2
parameters: {color: 128, detune: 100, gain: 128, phase: 0, shape: 64, stereo: 0, transpose: 64, type: 1, unison: 3}
- type: oscillator
id: 10
parameters: {color: 128, detune: 27, gain: 102, lfo: 0, phase: 71, shape: 64, stereo: 0, transpose: 76, type: 1, unison: 3}
- type: addp
id: 11
parameters: {stereo: 0}
- type: noise
id: 23
parameters: {gain: 67, shape: 114, stereo: 0}
- type: addp
id: 24
parameters: {stereo: 0}
- type: mulp
id: 17
parameters: {stereo: 0}
- id: 18
parameters: {}
- type: envelope
id: 12
parameters: {attack: 18, decay: 70, gain: 64, release: 64, stereo: 0, sustain: 64}
- type: oscillator
id: 13
parameters: {color: 128, detune: 31, gain: 128, phase: 78, shape: 64, stereo: 0, transpose: 64, type: 1, unison: 3}
- type: oscillator
id: 14
parameters: {color: 128, detune: 96, gain: 128, lfo: 0, phase: 54, shape: 64, stereo: 0, transpose: 76, type: 1, unison: 3}
- type: addp
id: 28
parameters: {stereo: 0}
- type: noise
id: 27
parameters: {gain: 80, shape: 128, stereo: 0}
- type: addp
id: 15
parameters: {stereo: 0}
- type: mulp
id: 26
parameters: {stereo: 0}
- type: delay
parameters: {damp: 0, dry: 0, feedback: 0, notetracking: 0, pregain: 128, stereo: 0}
varargs: [69]
- type: pan
parameters: {panning: 60, stereo: 1}
- type: filter
id: 19
parameters: {bandpass: 0, frequency: 128, highpass: 0, lowpass: 1, negbandpass: 0, neghighpass: 0, resonance: 128, stereo: 1}
- type: filter
id: 22
parameters: {bandpass: 1, frequency: 69, highpass: 0, lowpass: 1, negbandpass: 1, neghighpass: 1, resonance: 128, stereo: 1}
- type: outaux
id: 6
parameters: {auxgain: 0, outgain: 64, stereo: 1}
- type: envelope
id: 20
parameters: {attack: 67, decay: 0, gain: 128, release: 86, stereo: 0, sustain: 120}
- type: invgain
parameters: {invgain: 74, stereo: 0}
- parameters: {}
- type: send
id: 21
parameters: {amount: 48, port: 0, sendpop: 1, stereo: 0, target: 19, unit: 0, voice: 0}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: BassAdam
name: Bass (Adam)
comment: |
Author: pestis/bC!. Suggested note: F#1. Originally from: 4k intro Adam.

Expand All @@ -12,15 +12,15 @@ comment: |
numvoices: 1
units:
- type: envelope
parameters: {attack: 48, decay: 63, gain: 128, release: 64, stereo: 0, sustain: 0}
parameters: {attack: 36, decay: 59, gain: 128, release: 52, stereo: 0, sustain: 25}
- type: distort
parameters: {drive: 112, stereo: 0}
- type: oscillator
parameters: {color: 0, detune: 64, gain: 128, looplength: 1486, loopstart: 2536, phase: 64, samplestart: 250849, shape: 64, stereo: 0, transpose: 64, type: 1, unison: 0}
- type: mulp
parameters: {stereo: 0}
- type: filter
parameters: {bandpass: 0, frequency: 16, highpass: 1, lowpass: 0, negbandpass: 0, neghighpass: 0, resonance: 128, stereo: 0}
parameters: {bandpass: 0, frequency: 13, highpass: 1, lowpass: 0, negbandpass: 0, neghighpass: 0, resonance: 128, stereo: 0}
- type: filter
id: 1
parameters: {bandpass: 0, frequency: 22, highpass: 0, lowpass: 1, negbandpass: 0, neghighpass: 0, resonance: 128, stereo: 0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ numvoices: 1
units:
- type: envelope
id: 1
parameters: {attack: 0, decay: 64, gain: 128, release: 76, stereo: 0, sustain: 64}
parameters: {attack: 0, decay: 64, gain: 55, release: 76, stereo: 0, sustain: 64}
- type: send
id: 2
parameters: {amount: 112, port: 4, sendpop: 0, target: 1}
- type: oscillator
id: 3
parameters: {color: 64, detune: 64, gain: 128, lfo: 0, phase: 0, shape: 64, stereo: 0, transpose: 52, type: 2}
parameters: {color: 64, detune: 64, gain: 106, lfo: 0, phase: 0, shape: 64, stereo: 0, transpose: 52, type: 2}
- type: oscillator
id: 4
parameters: {color: 0, detune: 64, gain: 128, lfo: 0, phase: 0, shape: 64, stereo: 0, transpose: 64, type: 1}
parameters: {color: 0, detune: 64, gain: 122, lfo: 0, phase: 0, shape: 64, stereo: 0, transpose: 64, type: 1}
- type: addp
id: 5
parameters: {stereo: 0}
- type: envelope
id: 6
parameters: {attack: 0, decay: 66, gain: 128, release: 64, stereo: 0, sustain: 16}
parameters: {attack: 0, decay: 70, gain: 128, release: 70, stereo: 0, sustain: 18}
- type: send
id: 214
parameters: {amount: 96, port: 0, sendpop: 0, target: 10}
Expand All @@ -27,20 +27,16 @@ units:
parameters: {amount: 96, port: 0, sendpop: 1, target: 11}
- type: filter
id: 10
parameters: {bandpass: 0, frequency: 12, highpass: 0, lowpass: 1, negbandpass: 0, neghighpass: 0, resonance: 128, stereo: 0}
parameters: {bandpass: 0, frequency: 39, highpass: 0, lowpass: 1, negbandpass: 0, neghighpass: 0, resonance: 74, stereo: 0}
- type: filter
id: 11
parameters: {bandpass: 0, frequency: 12, highpass: 0, lowpass: 1, negbandpass: 0, neghighpass: 0, resonance: 128, stereo: 0}
parameters: {bandpass: 0, frequency: 11, highpass: 0, lowpass: 1, negbandpass: 0, neghighpass: 0, resonance: 128, stereo: 0}
- type: mulp
id: 12
parameters: {stereo: 0}
- type: delay
id: 13
parameters: {damp: 64, dry: 128, feedback: 64, notetracking: 2, pregain: 64, stereo: 0}
varargs: [36]
- type: pan
id: 14
parameters: {panning: 64, stereo: 0}
- type: outaux
id: 15
parameters: {auxgain: 4, outgain: 128, stereo: 1}
parameters: {auxgain: 4, outgain: 62, stereo: 1}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading