Karya, built on Sun Nov 26 01:04:37 PST 2017 (patch 0a920b2bde70c0cbac8ee09d158064798b61bbe5)

Safe HaskellNone




Utility functions for derive tests.



signal_interpolate :: RealTime.RealTime -> Signal.Y -> RealTime.RealTime -> Signal.Y -> [(RealTime.RealTime, Signal.Y)] Source #

Simulate the linear interpolate call, to check deriver output that involves that particular call.

Drops the first sample to make this match output from the derive call interpolators.


run_ :: Ui.State -> Deriver a -> Either Text (a, State, [Log.Msg]) Source #

Run without a fake stack.

extract_run :: (a -> b) -> Either Text (a, State, [Log.Msg]) -> Either Text b Source #

run_events :: (a -> b) -> Either Text ([LEvent.LEvent a], State, [Log.Msg]) -> Either Text ([b], [Text]) Source #


perform_result :: (Stream.Stream Score.Event -> (a, [Log.Msg])) -> Result -> (a, [Text]) Source #

Chain a perform from a Derive.Result.


derive_tracks_linear :: Text -> [UiTest.TrackSpec] -> Result Source #

Derive tracks but with a linear skeleton. Good for testing note transformers since the default skeleton parsing won't create those.

derive_tracks_setup :: Setup -> Text -> [UiTest.TrackSpec] -> Result Source #

Variant that lets you run setup on various states.

derive block variations

derive_blocks :: [UiTest.BlockSpec] -> Result Source #

Create multiple blocks, and derive the first one.

derive_block_setup :: Setup -> Ui.State -> Id.BlockId -> Result Source #

Derive a block with the testing environ.

derive_dump :: [MidiInst.Synth] -> Simple.State -> Id.BlockId -> Result Source #

Derive the results of a Cmd.Repl.LDebug.dump_block.

derive_block_standard :: Setup -> Cmd.State -> Cache -> ScoreDamage -> Ui.State -> Id.BlockId -> Result Source #

Derive a block in the same way that the app does.


run_cmd :: CallStack.Stack => Ui.State -> Cmd.State -> Cmd.CmdId a -> a Source #

CmdTest also has this, but I can't import it because it imports DeriveTest.


data SetupA a Source #

This file only ever uses Setup, but it loses polymorphism. To reuse with_* functions in a polymorphic way, I can use SetupA and pull them back out with setup_deriver.


Monoid (SetupA a) # 


mempty :: SetupA a #

mappend :: SetupA a -> SetupA a -> SetupA a #

mconcat :: [SetupA a] -> SetupA a #


with_linear :: Setup Source #

Set the skeleton of the tracks to be linear, i.e. each track is the child of the one to the left. This overrides the default behaviour of figuring out a skeleton by making note tracks start their own branches.

with_ruler :: Id.BlockId -> Ruler.Ruler -> Setup Source #

Set the ruler on the given block.


modify_constant :: (Constant -> Constant) -> SetupA a Source #

I'm not really supposed to do this, but should be *mostly* ok for tests. It's not entirely ok because some values are baked in to e.g. lookup functions.

modify_dynamic :: (Dynamic -> Dynamic) -> Deriver () Source #

Not supposed to do this in general, but it's ok for tests.

setup multiple

with_synths :: UiConfig.Allocations -> [MidiInst.Synth] -> Setup Source #

Derive with a bit of a real instrument db. Useful for testing instrument calls.

merge_allocs :: CallStack.Stack => [MidiInst.Synth] -> UiConfig.Allocations -> UiConfig.Allocations Source #

Merge the incomplete Allocations with the Patch defaults. Crash if it doesn't like you. TODO unused... maybe I don't really need this?

with_patch :: (MidiInst.Patch -> MidiInst.Patch) -> Text -> Setup Source #

Add a single instrument with a MIDI patch.

allocs_from_db :: Cmd.InstrumentDb -> Simple.Allocations -> UiConfig.Allocations Source #

Use the db to infer Patch.Settings for the allocations. The simple version doesn't record the Patch.config_settings, so I get the defaults.

type SimpleAllocations = [(Text, Text)] Source #

A further-simplified version of Simple.Allocations for tests: [(Instrument, Qualified)]

lookup_settings :: Cmd.InstrumentDb -> InstTypes.Qualified -> Maybe Patch.Settings Source #

This uses patch_defaults for settings, since I don't have a config.


cmd_config :: Cmd.InstrumentDb -> Cmd.Config Source #

Config to initialize the Cmd.State.

instrument defaults

make_convert_lookup_for :: Score.Instrument -> Patch.Config -> Patch.Patch -> Lookup Source #

Make a Lookp for a single patch.


log msgs

trace_logs :: [Log.Msg] -> a -> a Source #

trace_low_prio :: [Log.Msg] -> [Log.Msg] Source #

Filter out low-priority logs and trace them.

interesting_log :: Log.Msg -> Bool Source #

Tests generally shouldn't depend on logs below a certain priority since those don't indicate anything interesting.


extract :: (Score.Event -> a) -> Result -> ([a], [Text]) Source #

extract_levents :: (a -> b) -> [LEvent.LEvent a] -> ([b], [Text]) Source #

e_nns :: CallStack.Stack => Score.Event -> [(RealTime.RealTime, Pitch.NoteNumber)] Source #

Like e_nns_errors, but throw an exception if there are errors. Also drops duplicate samples for reasons described in unsignal_unique.

e_nns_rounded :: Score.Event -> [(RealTime.RealTime, Pitch.NoteNumber)] Source #

Like e_nns, but round to cents to make comparison easier.

e_nns_errors :: Score.Event -> ([(RealTime.RealTime, Pitch.NoteNumber)], [Text]) Source #

Extract pitch signal and any errors flattening it.

e_note :: Score.Event -> (RealTime.RealTime, RealTime.RealTime, Text) Source #

(start, dur, pitch), the melodic essentials of a note.

extract log msgs

extract midi msgs

interesting_midi :: [Midi.WriteMessage] -> [Midi.WriteMessage] Source #

Filter out boring msgs that I don't want tests to rely on.

ui state




type EventSpec = (RealTime.RealTime, RealTime.RealTime, Text, Controls, Score.Instrument) Source #

(start, dur, pitch12, controls, inst)

create misc

simple_midi_config :: Patch.Config Source #

A simple config for testing. It's only suitable for tests because normally a Config will have its Patch.config_settings initialized from the Patch.