Karya, built on 2020-11-26T21:03:17 (patch 23b5be2d53a9e8e7d6136cda5aae2849abe5cded)
Safe HaskellNone

Synth.Shared.Config

Description

Shared config to coordinate between the sequencer and im subsystems.

Synopsis

Documentation

type ChunkNum = Int Source #

Index into the audio chunks for a single instrument render. This is the same as ChunkNum.

type InstrumentName = Text Source #

This is the same as InstrumentName but I don't want to import that here.

data Config Source #

Constructors

Config 

Fields

  • imDir :: IO.FilePath

    All of the data files used by the Im backend are based in this directory. Everything in here should be temporary files, used for communication or caching.

  • synths :: Map SynthName Synth
     

Instances

Instances details
Eq Config # 
Instance details

Defined in Synth.Shared.Config

Methods

(==) :: Config -> Config -> Bool #

(/=) :: Config -> Config -> Bool #

Show Config # 
Instance details

Defined in Synth.Shared.Config

data Synth Source #

Constructors

Synth 

Fields

Instances

Instances details
Eq Synth # 
Instance details

Defined in Synth.Shared.Config

Methods

(==) :: Synth -> Synth -> Bool #

(/=) :: Synth -> Synth -> Bool #

Show Synth # 
Instance details

Defined in Synth.Shared.Config

Methods

showsPrec :: Int -> Synth -> ShowS #

show :: Synth -> String #

showList :: [Synth] -> ShowS #

samplerRoot :: Path.Relative Source #

Base directory for sampler patches.

unsafeSamplerRoot :: IO.FilePath Source #

This is samplerRoot, but as an absolute path.

Technically, Path.get_app_dir is in IO, so I can't get an absolute path without IO. However, I need to put the absolute path in the OSC play msgs (ultimately since play_cache runs with an unknown CWD), and it gets really annoying to try to get a Path.AppDir into the thru function's closure. So unsafePerformIO it is. I could probably just put that on app_dir, but this is the only thing that actually needs it.

notesParentDir :: IO.FilePath Source #

All serialized notes are in im / notesParentDir.

cacheDir :: IO.FilePath Source #

All rendered output is in im / cacheDir.

samplingRate :: Int Source #

All im synths render at this sampling rate, and the sequencer sets the start time by it.

type SamplingRate = 44100 Source #

chunkSize :: AudioT.Frames Source #

Save an audio chunk and checkpoint in this many frames.

A smaller size will lead to more checkpoints, which means finer grained caching, but more overhead saving the intermediate states. So a slower synthesizer with smaller state should use small chunks, fast rendering or large state imply large chunks. I could in theory adjust this per synthesizer, though currently karya relies on it being constant.

blockSize :: AudioT.Frames Source #

Number of frames in each audio block. A chunk corresponds to the output file size, and the block is the internal processing size.

To make sure checkpoint states line up with the file boundaries, this must divide into chunkSize.

startLatency :: AudioT.Frames Source #

play_cache delays play start by this many frames, so MIDI output should also be delayed by this much to match.

It has to cue up the sample streaming, which means it has to find and seek to the right file. If playback starts immediately then the first chunk gets cut off, which cuts off note attacks.

cache files

notesFilename Source #

Arguments

:: IO.FilePath 
-> IO.FilePath

Path to the score, relative to the save dir. This should uniquely identify this score.

-> Id.BlockId 
-> Synth 
-> IO.FilePath 

Write serialized notes to this file.

chunkPath :: IO.FilePath -> IO.FilePath -> Id.BlockId -> Text -> ChunkNum -> IO.FilePath Source #

Get the filename for a particular checkpoint.

isOutputLink :: IO.FilePath -> Maybe.Maybe ChunkNum Source #

This relies on the format from chunkPath.

playFilename :: IO.FilePath -> Id.BlockId -> IO.FilePath Source #

This is text sent over MIDI to tell play_cache which directory to play from. Relative to imDir/cacheDir.

clearUnusedInstruments :: IO.FilePath -> HashSet Note.InstrumentName -> IO.IO () Source #

Delete output links for instruments that have disappeared entirely. This often happens when I disable a track.

progress

data Message Source #

Instances

Instances details
Show Message # 
Instance details

Defined in Synth.Shared.Config

Generics.Generic Message # 
Instance details

Defined in Synth.Shared.Config

Associated Types

type Generics.Rep Message :: Type -> Type #

ToJSON Message # 
Instance details

Defined in Synth.Shared.Config

FromJSON Message # 
Instance details

Defined in Synth.Shared.Config

type Generics.Rep Message # 
Instance details

Defined in Synth.Shared.Config

data Payload Source #

Constructors

RenderingRange !RealTime !RealTime 
WaveformsCompleted ![ChunkNum]

Completed waveforms.

Warn !Stack.Stack !Text 
Failure !Text

A failure will cause karya to log the msg and mark the track as incomplete. It should be fatal, so don't do any emitMessage afterwards.

Instances

Instances details
Show Payload # 
Instance details

Defined in Synth.Shared.Config

Generics.Generic Payload # 
Instance details

Defined in Synth.Shared.Config

Associated Types

type Generics.Rep Payload :: Type -> Type #

ToJSON Payload # 
Instance details

Defined in Synth.Shared.Config

FromJSON Payload # 
Instance details

Defined in Synth.Shared.Config

type Generics.Rep Payload # 
Instance details

Defined in Synth.Shared.Config

type Generics.Rep Payload = Generics.D1 ('Generics.MetaData "Payload" "Synth.Shared.Config" "main" 'False) ((Generics.C1 ('Generics.MetaCons "RenderingRange" 'Generics.PrefixI 'False) (Generics.S1 ('Generics.MetaSel ('Maybe.Nothing :: Maybe.Maybe Symbol) 'Generics.NoSourceUnpackedness 'Generics.SourceStrict 'Generics.DecidedStrict) (Generics.Rec0 RealTime) Generics.:*: Generics.S1 ('Generics.MetaSel ('Maybe.Nothing :: Maybe.Maybe Symbol) 'Generics.NoSourceUnpackedness 'Generics.SourceStrict 'Generics.DecidedStrict) (Generics.Rec0 RealTime)) Generics.:+: Generics.C1 ('Generics.MetaCons "WaveformsCompleted" 'Generics.PrefixI 'False) (Generics.S1 ('Generics.MetaSel ('Maybe.Nothing :: Maybe.Maybe Symbol) 'Generics.NoSourceUnpackedness 'Generics.SourceStrict 'Generics.DecidedStrict) (Generics.Rec0 [ChunkNum]))) Generics.:+: (Generics.C1 ('Generics.MetaCons "Warn" 'Generics.PrefixI 'False) (Generics.S1 ('Generics.MetaSel ('Maybe.Nothing :: Maybe.Maybe Symbol) 'Generics.NoSourceUnpackedness 'Generics.SourceStrict 'Generics.DecidedStrict) (Generics.Rec0 Stack.Stack) Generics.:*: Generics.S1 ('Generics.MetaSel ('Maybe.Nothing :: Maybe.Maybe Symbol) 'Generics.NoSourceUnpackedness 'Generics.SourceStrict 'Generics.DecidedStrict) (Generics.Rec0 Text)) Generics.:+: Generics.C1 ('Generics.MetaCons "Failure" 'Generics.PrefixI 'False) (Generics.S1 ('Generics.MetaSel ('Maybe.Nothing :: Maybe.Maybe Symbol) 'Generics.NoSourceUnpackedness 'Generics.SourceStrict 'Generics.DecidedStrict) (Generics.Rec0 Text))))

pathToBlockId :: IO.FilePath -> Id.BlockId Source #

Infer namespace/block from ...imcache$scorePath$scoreFname$namespace$block/$instrument