Karya, built on 2023-08-29T07:47:28 (patch 7a412d5d6ba4968ca4155ef276a062ccdeb9109a)
Safe HaskellSafe-Inferred

Synth.Sampler.Patch.Lib.Drum

Description

Utilities shared between drum patches.

The base structure is that a drum has an enumeration of articulations, where each one is a directory of samples of increasing dynamics. There are an arbitrary number of samples, which may or may not be normalized, which form a continuum, rather than having explicit dynamic groups. Since there are no explicit variation samples, variation takes neighbor dynamics, where the variation range is defined per-patch.

There is a Common.AttributeMap mapping attrs to each articulation.

Synopsis

patch

patch :: Ord art => FilePath -> Note.PatchName -> StrokeMap art -> ConvertMap art -> (Maybe.Maybe art -> CUtil.CallConfig) -> Patch.Patch Source #

Make a complete sampler patch with all the drum bits.

karyaPatch :: FilePath -> StrokeMap art -> ConvertMap art -> (Maybe.Maybe art -> CUtil.CallConfig) -> [(Maybe.Maybe Char, Expr.Symbol, Generator Note)] -> ImInst.Patch Source #

Make a patch with the drum-oriented code in there already.

makePatch :: Common.AttributeMap a -> Bool -> ImInst.Patch Source #

Make an unconfigured patch, without code, in case it's too custom for karyaPatch.

convert

data ConvertMap art Source #

Arguments for the convert function.

Constructors

ConvertMap 

Fields

  • _dynRange :: (Y, Y)

    Dyn from 0 to 1 will be scaled to this range. If the samples are not normalized, and there are enough for a smooth curve, then (1, 1) should do.

    TODO: if the samples are not normalized, I need a separate range for each sample, to smooth out the differences.

  • _naturalNn :: Maybe.Maybe (art -> Pitch.NoteNumber)

    If Just, use the note's pitch, assuming ratio=1 will be this pitch.

  • _muteTime :: Maybe.Maybe RealTime.RealTime

    Time to mute at the end of a note.

  • _getFilename :: art -> Y -> Y -> (FilePath, Maybe.Maybe (Y, Y))

    articulation -> dynamic -> variation -> (FilePath, (lowDyn, highDyn)). Returning the sample's dyn range was an attempt to tune dyn globally, but I think it doesn't work, see TODO above.

  • _allFilenames :: Set FilePath
     

variableDynamic Source #

Arguments

:: Show art 
=> Y

A note may pick a sample of this much dyn difference on either side.

-> (art -> [FilePath]) 
-> art -> Y -> Y -> (FilePath, Maybe.Maybe a) 

Create a _getFilename with the strategy where each articulation has a [FilePath], sorted evenly over the dynamic range.

convert :: Common.AttributeMap art -> ConvertMap art -> Note.Note -> Patch.ConvertM Sample.Sample Source #

Make a generic convert, suitable for drum type patches.

StrokeMap

data StrokeMap art Source #

Describe a drum-like instrument. This is just the data for the various functions to construct the patch.

Constructors

StrokeMap 

Fields

Instances

Instances details
Show art => Show (StrokeMap art) Source # 
Instance details

Defined in Synth.Sampler.Patch.Lib.Drum

Methods

showsPrec :: Int -> StrokeMap art -> ShowS #

show :: StrokeMap art -> String #

showList :: [StrokeMap art] -> ShowS #

strokeMapSimple :: Ord art => Drums.Stops -> [(Char, Expr.Symbol, Attrs.Attributes, art, Drums.Group)] -> StrokeMap art Source #

Like strokeMapTable, but for patches with only Strokes.

data Call art Source #

Constructors

Call (Generator Note)

A call that doesn't correspond directly to Attributes.

Stroke Attrs.Attributes art Drums.Group

Emit a call that produces these Attributes, and cause the patch to assign those Attributes to the given articulation.

Attr Attrs.Attributes

Emit a call that produces these Attributes, with no articulation association.

strokeMapTable Source #

Arguments

:: Ord art 
=> Drums.Stops 
-> [(Char, Expr.Symbol, Call art)]

If Char == ' ', there is no key binding. Symbol == "" means there is no call, but it still makes sense for Stroke, because it can make the patch respond to the given Attributes.

-> StrokeMap art 

Make a StrokeMap describing the keymap and call map of a drum-like patch.

replaceSoft :: Y -> StrokeMap art -> StrokeMap art Source #

Set dynamic for Attrs.soft and remove it.

strokeMap :: Ord art => Drums.Stops -> [Drums.Stroke] -> Common.AttributeMap art -> StrokeMap art Source #

Make a StrokeMap from separate strokes and AttributeMap. This happens when instruments parts are factored apart, due to having both MIDI and im versions.

stopMap :: Ord art => [(art, Drums.Group)] -> [(Drums.Group, [Drums.Group])] -> Map art (Set art) Source #

inferDuration

inferDuration :: Ord art => StrokeMap art -> [Note.Note] -> [Note.Note] Source #

Notes ring until stopped by their stop note.

file list

makeFileList :: FilePath -> [FilePath] -> String -> IO () Source #

Generate haskell code for an Articulation -> [FilePath] function.

This expects a subdirectory for each articulation, whose name is the same as the Articulation constructor, and sorts it on the last numeric dash-separated field.

This could be done with TH but it's constant so it's simpler to copy paste into the source.

enumFunction :: (Typeable.Typeable a, Show a, Typeable.Typeable b, Pretty b) => String -> [(a, [b])] -> [String] Source #

Emit haskell code for a function from an Enum to lists.