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

Derive.C.India.Gamakam2

Description

Calls for Carnatic gamakam.

Synopsis

# Documentation

Calls in these modules are meant to be used via the sequence call, so they are only in scope under the relevant phase.

Calls in these modules are meant to be used via the sequence call, so they are only in scope under the relevant phase.

Calls in these modules are meant to be used via the sequence call, so they are only in scope under the relevant phase.

I don't want to take up short names for the whole track scope, but within a sequence call it seems reasonable. In addition, I know if it's a begin or end call, and use the same name for logically similar things.

alias_prefix :: Text -> Text -> [(Expr.Symbol, call)] -> [(Expr.Symbol, call)] Source #

Special behaviour documented in sequence_doc.

Unlike fade_out_call, this doesn't need special treatment.

# sequence

sequence_calls :: Context Pitch -> (ScoreTime, ScoreTime) -> Expr -> [Expr] -> Maybe Expr -> Deriver Signals Source #

I assume that start and end calls have a fixed duration and don't stretch to fill the given space, though they will shrink if necessary. So I evaluate start and end to get their durations, and fit the middle calls into the remaining space, evenly divided.

Actually, there's a circular problem in that I don't know how long the middle section can be until I know how long the end call is, but the end call likely relies on ctx_prev_val, so it has to be evaluated after the middle. So I evaluate the end twice, once before the middle to find out its length, and again after evaluating the middle to get the pitch right.

I considered a specially calling mode where calls could return their desired duration rather than a signal, but it seems much simpler to just have them do that by returning the signal itself and measuring that.

A possibly useful extension would be to allow middle calls to be shorter than their allotted time, for instance a trill might want to complete a cycle and allow a flat call to take up remaining space. I could put the requested time in Derive.real 1 and the hard limit in Args.next, but that wouldn't allow time before the call to stretch, only time after. But I could indicate stretchiness with a special tag on the call.

Special behaviour for the fade-out call, as documented in sequence_doc.

I need to thread Derive.ctx_prev_val from each call in the sequence.

Give each middle call an even division of the time left. The call can use less time if it wishes, and the remaining time will be divided among the remaining middle calls. It shouldn't use more time, because then it could overlap with the end call, or go past the end of the note.

## parse

data Expr Source #

Constructors

 EvaluatedExpr Expr.Symbol [DeriveT.Val] This is a call which was embedded in the argument list of the sequence call, so its arguments have already been evaluated. QuotedExpr !DeriveT.Expr A call and its arguments can be protected from evaluation by quoting it. This is also necessary to use a transformer, since ; has higher precedence than | (actually it's just a value, not an operator).

#### Instances

Instances details
 # Instance detailsDefined in Derive.C.India.Gamakam2 MethodsshowsPrec :: Int -> Expr -> ShowS #show :: Expr -> String #showList :: [Expr] -> ShowS # # Instance detailsDefined in Derive.C.India.Gamakam2 MethodsformatList :: [Expr] -> Doc Source #

parse_sequence :: [DeriveT.Val] -> (Expr, [Expr], Maybe Expr) Source #

Parse the sequence call's arguments and substitute aliases. If there is no begin, set-pitch will be added, and if there is no middle, - will be added. This is so that if there is just an end call, there will still be a signal from the beginning of the note.

The positions are inferred according to the number of sections:

; middle1;
begin1; middle2
begin1; middle2; middle3; ...; end_n

# start

data PitchFrom Source #

Constructors

 PitchFromPrev PitchFromCurrent

#### Instances

Instances details
 # Instance detailsDefined in Derive.C.India.Gamakam2 Methods # Instance detailsDefined in Derive.C.India.Gamakam2 MethodsshowList :: [PitchFrom] -> ShowS #

Constructors

#### Instances

Instances details
 # Instance detailsDefined in Derive.C.India.Gamakam2 Methods(==) :: Fade -> Fade -> Bool #(/=) :: Fade -> Fade -> Bool # # Instance detailsDefined in Derive.C.India.Gamakam2 MethodsshowsPrec :: Int -> Fade -> ShowS #show :: Fade -> String #showList :: [Fade] -> ShowS #

Get the end time, given a start and a duration. Don't go beyond the maximum, which is the event's duration, if given explicitly, or the next event if it's 0.

# middle

## kampita

Constructors

 Kampita0 !Signal.Y !Signal.Y Both interval arguments are hardcoded. Kampita1 !Signal.Y The starting pitch is hardcoded. Kampita2 Both arguments must be provided.

#### Instances

Instances details
 # Instance detailsDefined in Derive.C.India.Gamakam2 MethodsshowList :: [KampitaArgs] -> ShowS #

## implementation

You don't think there are too many arguments, do you?

Make a trill signal from a list of transition times.

# end

Subtract the duration from the given end time, but don't go past the start.

# util

This defaults to the note's base pitch, in case this call is the first one. Also, the end call is called before the middle calls to find out how long it is.

A number of calls take an optional pitch, and default to either the current or previous pitch.