mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-27 01:14:57 -04:00
further drafting
This commit is contained in:
parent
bd20440661
commit
964b2adbab
@ -118,7 +118,11 @@ type (
|
||||
ParamName string
|
||||
}
|
||||
|
||||
ExtParamArray [ExtParamCount]float32
|
||||
ExtValueArray [ExtParamCount]float32
|
||||
ExtParamArray [ExtParamCount]struct {
|
||||
Val float32
|
||||
Param sointu.UnitParameter
|
||||
}
|
||||
|
||||
IsPlayingMsg struct{ bool }
|
||||
StartPlayMsg struct{ sointu.SongPos }
|
||||
@ -374,8 +378,8 @@ func (m *Model) ProcessPlayerMessage(msg PlayerMsg) {
|
||||
m.Alerts().AddAlert(e)
|
||||
case IsPlayingMsg:
|
||||
m.playing = e.bool
|
||||
case ExtParamArray:
|
||||
m.SetExtParams(e)
|
||||
case ExtValueArray:
|
||||
m.SetExtValues(e)
|
||||
default:
|
||||
}
|
||||
}
|
||||
@ -410,7 +414,7 @@ func (m *Model) Instrument(index int) sointu.Instrument {
|
||||
return m.d.Song.Patch[index].Copy()
|
||||
}
|
||||
|
||||
func (m *Model) ExtParams() (ret ExtParamArray) {
|
||||
func (m *Model) ExtParams() (params ExtParamArray) {
|
||||
for i, l := range m.d.ExtParamLinks {
|
||||
instrIndex, unitIndex, err := m.d.Song.Patch.FindUnit(l.UnitID)
|
||||
if err != nil {
|
||||
@ -420,7 +424,8 @@ func (m *Model) ExtParams() (ret ExtParamArray) {
|
||||
if up, ok := sointu.UnitTypes[unit.Type]; ok {
|
||||
for _, p := range up {
|
||||
if p.Name == l.ParamName && p.CanSet && p.MaxValue > p.MinValue {
|
||||
ret[i] = float32(unit.Parameters[l.ParamName]-p.MinValue) / float32(p.MaxValue-p.MinValue)
|
||||
params[i].Val = float32(unit.Parameters[l.ParamName]-p.MinValue) / float32(p.MaxValue-p.MinValue)
|
||||
params[i].Param = p
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -428,8 +433,8 @@ func (m *Model) ExtParams() (ret ExtParamArray) {
|
||||
return
|
||||
}
|
||||
|
||||
func (m *Model) SetExtParams(params ExtParamArray) {
|
||||
defer m.change("SetParamValue", PatchChange, MinorChange)()
|
||||
func (m *Model) SetExtValues(vals ExtValueArray) {
|
||||
defer m.change("SetExtValues", PatchChange, MinorChange)()
|
||||
changed := false
|
||||
for i, l := range m.d.ExtParamLinks {
|
||||
instrIndex, unitIndex, err := m.d.Song.Patch.FindUnit(l.UnitID)
|
||||
@ -440,7 +445,7 @@ func (m *Model) SetExtParams(params ExtParamArray) {
|
||||
if up, ok := sointu.UnitTypes[unit.Type]; ok {
|
||||
for _, p := range up {
|
||||
if p.Name == l.ParamName && p.CanSet && p.MaxValue > p.MinValue {
|
||||
newVal := int(math.Round(float64(params[i])*float64(p.MaxValue-p.MinValue))) + p.MinValue
|
||||
newVal := int(math.Round(float64(vals[i])*float64(p.MaxValue-p.MinValue))) + p.MinValue
|
||||
if unit.Parameters[l.ParamName] != newVal {
|
||||
unit.Parameters[l.ParamName] = newVal
|
||||
changed = true
|
||||
|
@ -21,8 +21,8 @@ func (NullContext) BPM() (bpm float64, ok bool) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func (NullContext) Params() (params tracker.ExtParamArray, ok bool) {
|
||||
return tracker.ExtParamArray{}, false
|
||||
func (NullContext) Params() (params tracker.ExtValueArray, ok bool) {
|
||||
return tracker.ExtValueArray{}, false
|
||||
}
|
||||
|
||||
func (NullContext) SetParams(params tracker.ExtParamArray) bool {
|
||||
|
@ -25,7 +25,7 @@ type (
|
||||
voiceLevels [vm.MAX_VOICES]float32 // a level that can be used to visualize the volume of each voice
|
||||
voices [vm.MAX_VOICES]voice
|
||||
loop Loop
|
||||
extParamValues ExtParamArray
|
||||
extParamValues ExtValueArray
|
||||
|
||||
recState recState // is the recording off; are we waiting for a note; or are we recording
|
||||
recording Recording // the recorded MIDI events and BPM
|
||||
@ -40,7 +40,7 @@ type (
|
||||
PlayerProcessContext interface {
|
||||
NextEvent() (event MIDINoteEvent, ok bool)
|
||||
BPM() (bpm float64, ok bool)
|
||||
Params() (params ExtParamArray, ok bool)
|
||||
Params() (params ExtValueArray, ok bool)
|
||||
SetParams(params ExtParamArray) bool
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user