-- Copyright 2018 Evan Laforge
-- This program is distributed under the terms of the GNU General Public
-- License 3.0, see COPYING or http://www.gnu.org/licenses/gpl-3.0.txt

-- | Local instrument definition with nothing in it.  If you have MIDI
-- instruments you'll want to put some basic configuration in here.
-- See User\/Elaforge\/Instrument for examples.
module User.Generic.Instrument (midi_synths, all_loads) where
import qualified Cmd.Instrument.MidiInst as MidiInst
import qualified Derive.ScoreT as ScoreT
import qualified Instrument.InstT as InstT
import qualified Midi.Midi as Midi
import qualified User.Generic.Instrument.GeneralMidi as GeneralMidi
import qualified User.Generic.Instrument.OBXd as OBXd
import qualified User.Generic.Instrument.Surge as Surge


-- | Synth declarations for each synth that is declared purely.
midi_synths :: [MidiInst.Synth]
midi_synths :: [Synth]
midi_synths =
    [ Synth
generic_synth
    , Synth
GeneralMidi.synth
    , Synth
OBXd.synth
    , Synth
Surge.synth
    ]

-- | Each synth that caches to disk has a function to make the cache, and one
-- to load it.
all_loads :: [(InstT.SynthName, (MidiInst.MakeDb, MidiInst.Load))]
all_loads :: [(SynthName, (MakeDb, Load))]
all_loads = []

generic_synth :: MidiInst.Synth
generic_synth :: Synth
generic_synth =
    SynthName -> SynthName -> [Patch] -> Synth
MidiInst.synth SynthName
"generic"
        SynthName
"Generic MIDI instrument with no special configuration." forall a b. (a -> b) -> a -> b
$
        [(Control, Control)] -> [Patch] -> [Patch]
MidiInst.synth_controls [(Control, Control)]
controls [Patch]
patches
    where
    -- Special control names, e.g.: (16, "morph-x"), (17, "morph-y")
    controls :: [(Midi.Control, ScoreT.Control)]
    controls :: [(Control, Control)]
controls = []

    patches :: [MidiInst.Patch]
    patches :: [Patch]
patches = [PbRange -> [(Control, Control)] -> Patch
MidiInst.default_patch PbRange
pb_range []]
    -- Pitch bend range.  Most MIDI patches default to a whole-step in each
    -- direction, which is pretty limiting.  You should configure yours to
    -- some wider range.
    pb_range :: PbRange
pb_range = (-Int
2, Int
2)