# score.core

### convert-measured-score

`(convert-measured-score score)`
```Converts a measured score into a single score list. The measured-score
is a single list that has the following shape:

[:meter 4 4
0 list0 list1
1 list0
2 list0 list1]

Given a meter of 4/4, process each value according the following rules:

* If a number is found, set that as current measure number.
* If a list is found, check if it is a single note or a list of notes.
If it is a list of notes, adjust start time using with-start and beat
value calculated to measure number.  If it is a single note, adjust
start time of the single note relative to the measure number.

For example, list0 is played at measure 0, 1, and 2,
while list1 is played only in measures 0 and 2.  If list1 had only one note
of [instr-func 0.0 1.0], then the generated score would have:

[[instr-func 0.0 1.0] [instr-func 8.0 1.0]]

This notation allows for organizing hierarchies of materials as lists
of notes. Note, notes within note lists must be in the format of:

[instr-func start-time optional-args...]```

### convert-timed-score

`(convert-timed-score score)`
```Converts a timed score into a single score list. The timed-score
is a single list that has the following shape:

[ 0 list0 list1
10 list0
20 list0 list1]

Processes each value according the following rules:

* If a number is found, set that as current start time in beats.
* If a list is found, check if it is a single note, a list of notes, or a
sub-timed-score.  If it is a list of notes, adjust start time using
with-start and current start-time.  If it is a single note, adjust start time
of the single note relative to the start-time given.  If it is a
sub-timed-score, process with convert-timed-score, then adjust start time
using with-start and current start-time.

For example, list0 is played at times 0, 10, and 20,
while list1 is played at times 0 and 20.  If list1 had only one note
of [instr-func 0.0 1.0], then the generated score would have:

[[instr-func 0.0 1.0] [instr-func 20.0 1.0]]

This notation allows for organizing hierarchies of materials as lists
of notes. Note, notes within note lists must be in the format of:

[instr-func start-time optional-args...]

This function will also return a score if it is not in timed-score format, which
in this case is tested by checking if the passed-in score is sequential and that
the first element is a number.```

### format-sco

`(format-sco notes)`
```Formats a list of notes into a Csound SCO string
```

### gen-notes

`(gen-notes & fields)`
```Generate notes by assembling sequences together into notes.
If a constant value is given, it will be wrapped with (repeat).
If a no-arg function is given, it will be wrapped with (repeatedly).```

### gen-notes2

`(gen-notes2 start dur & fields)`
```Generate notes with time-based generator functions. This score generation method
is based on CMask. Given fields should be single-arg functions that generate a
value based-on time argument.```

### gen-score

`(gen-score & fields)`
```Generates Csound score using gen-notes, then apply format-sco
```

### gen-score2

`(gen-score2 start dur & fields)`

### get-measure-beat-length

`(get-measure-beat-length meter-num meter-beats)`
```Gets beat length of measure given beat value and meter. I.e. for
beat = 4, and meter of 4 4, returns 4 beats as the measure length.```

### process-notes

#### macro

`(process-notes notelist & body)`
```Process given notelist using pairs of index and functions. For example,
using:

(process-notes notes
3 db->amp
4 keyword->freq)

will process each note in notes, converting the 4th field with db->amp and
5th field with keyword->freq.  Uses swapv! from pink.util.```

### rand-range

`(rand-range low high)`
```Generates random value between low and high
```

### repeat-seq

`(repeat-seq num-repeat items)``(repeat-seq num-repeat head items cur-iter)`
```Repeats sequence x number of times. Returns lazy-sequence.
```

### starting-at

`(starting-at start sco)`
```Given a starting time and given score, returns a note list where all notes with
starting times earlier than the given start are dropped, and all remaining notes
have their times translated relative to the start time.  Useful when developing
works to take a score start at a time somewhere in the middle, then send that off
to a running engine.```

### with-start

`(with-start start sco)`
```Translates note vectors in time by start value. Start may either be a double
value, where inde of start time in notes is assumed to be 1, or start may
also be given as a 2-vector in the form [index startime].```

### with-tempo

`(with-tempo tempo notes)``(with-tempo tempo note & notes)`
```Adjust note start and durations according to tempo. 1.0 equals one beat at
tempo.```

### wrap-generator

`(wrap-generator f)`