-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
NyquistAPI.h
143 lines (123 loc) · 6.36 KB
/
NyquistAPI.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/**********************************************************************
Audacity: A Digital Audio Editor
NyquistAPI.h
Roger B. Dannenberg
Apr 2021
Interface for Nyquist access to tracks and more
**********************************************************************/
// (AUD-GET-TRACK-INFO id) -- get a property list from track by name or index
// track index starts at 0, incremented by 1 for each multi-channel track
// E.g. if there are two stereo tracks, they are tracks 0 and 1.
// Properties are:
// NAME - the name (STRING)
// TYPE - WAVE, NOTE, or LABEL (SYMBOL)
// For type WAVE:
// CHANNELS - 1 or 2 (FIXNUM)
// CLIPS - ((start end) (start end) ...) for mono (LIST)
// or #( ((s e) (s e) ...) ((s e) (s e) ...) ) for
// stereo (ARRAY)
// For type NOTE and LABEL:
// no other properties, although if notes and labels were organized
// into clips, it would be appropriate to add a CLIPS property.
// Notes and labels are accessed using AUD-GET-LABELS and
// AUD-GET-NOTES
//
// (AUD-GET-AUDIO id start dur) -- return sound or array of sounds.
// id is name or number
// start is project time for start of sound (FLONUM)
// dur is duration in seconds (FLONUM)
// zeros are inserted as necessary to achieve the requested duration
//
// (AUD-PUT-AUDIO id expr start maxdur) -- write sound to a track
// id is name or number
// expr is a lisp expression to be evaluated to get a sound
// the expr must evaluate to a mono or stereo sound matching the track
// start is an offset time applied to the result of expr
// maxdur is the maximum duration (relative to start) for the sound
//
// (AUD-GET-LABELS id start dur) -- return labels.
// id is name or number
// start is project time for start of label region (FLONUM)
// dur is duration in seconds (FLONUM)
// returns list of labels: ((T0 T1 "label") (T0 T1 "label") ...)
// such that label T0 >= start and T0 < start + dur.
// Note that labels can have durations > 0 such that T1 > start + dur.
//
// (AUD-PUT-LABELS id labels merge) -- add/replace labels to track
// id is name or number
// labels is a label list in the format returned by AUD-GET-LABELS
// if merge is NULL, replace all labels in the track. Otherwise, merge.
//
// (AUD-GET-NOTES id start dur inbeats) -- return notes and updates from track
// If inbeats is NULL, all time units are in beats. Otherwise all units are
// seconds.
// id is name or number
// start is the project time for the start of a region (beats or seconds)
// dur is the duration for a region (beats or seconds)
// inbeats is NULL if times and durations are in seconds; o.w. beats
// returns a list of events with time >= start and time < start + dur
// each event in the returned list has one of two formats:
// (NOTE key time channel pitch loudness duration
// [parameter parameter ...])
// key is an event identifier, normally MIDI key number (FIXNUM)
// time is the start time (beats or seconds) (FLONUM)
// channel is the (usually MIDI) channel number (FIXNUM)
// pitch is the exact pitch in (fractional) half-steps (FLONUM)
// loudness is in MIDI velocity units (FLONUM)
// duration is event duration in beats or seconds (FLONUM)
// each parameter (optional) is a keyword followed by a value.
// The keyword prepends a colon (":") to the Allegro attribute
// name, retains the type code suffix, and converts all to
// upper case. Type code suffixes are:
// s[tring], r[eal], i[nteger], or l[ogical].
// Example: (NOTE 60 4.0 3 100.0 1.0 :COLORS "blue")
// (UPDATE key time channel parameter)
// key is an event identifier, normally MIDI key number (FIXNUM)
// time is the start time (beats or seconds) (FLONUM)
// channel is the (usually MIDI) channel number (FIXNUM)
// parameter is an attribute keyword followed by value as in NOTE.
//
// (AUD-PUT-NOTES id notes inbeats merge)
// id is name or number
// notes is an event list in the format returned by AUD-GET-NOTES
// any symbol may denote an attribute for a parameter. If the symbol
// name starts with ":", the colon is removed. The name is converted
// to lower case, and the last character must match the type of the
// parameter. For logical attributes, the value must be T or NIL.
// inbeats is NULL if times and durations are in seconds; o.w. beats
// if merge is NULL, replace all events in the track. Otherwise, merge.
//
// (AUD-GET-TIMES id start dur)
// id is name or number
// start is project time for start of region (FLONUM)
// dur is duration in seconds (FLONUM)
// returns list of breakpoints: ((x y) (x y) ...)
// such that label x >= start and x < start + dur.
//
// (AUD-PUT-TIMES id breakpoints) -- add/replace labels to track
// id is name or number
// breakpoints is a list in the format returned by AUD-GET-TIMES
// The entire track content is always replaced by the new breakpoints.
//
#ifndef __AUDACITY_NYQUISTAPI__
#define __AUDACITY_NYQUISTAPI__
void setNyquistProject(const AudacityProject* p);
LVAL getTrackInfo(LVAL nameOrNumber);
/* LISP: (AUD-GET-TRACK-INFO ANY) */
LVAL getAudio(LVAL nameOrNumber, double start, double dur);
/* LISP: (AUD-GET-AUDIO ANY ANYNUM ANYNUM) */
LVAL putAudio(LVAL nameOrNumber, LVAL expr, double start, double maxdur);
/* LISP: (AUD-PUT-AUDIO ANY ANY ANYNUM ANYNUM) */
LVAL getLabels(LVAL nameOrNumber, double start, double dur);
/* LISP: (AUD-GET-LABELS ANY ANYNUM ANYNUM) */
LVAL putLabels(LVAL nameOrNumber, LVAL labels, LVAL merge_flag);
/* LISP: (AUD-PUT-LABELS ANY ANY ANY) */
LVAL getNotes(LVAL nameOrNumber, double start, double dur, LVAL inbeats);
/* LISP: (AUD-GET-NOTES ANY ANYNUM ANYNUM ANY) */
LVAL putNotes(LVAL nameOrNumber, LVAL notes, LVAL inbeats, LVAL merge_flag);
/* LISP: (AUD-PUT-NOTES ANY ANY ANY ANY) */
LVAL getTimes(LVAL nameOrNumber, double start, double dur);
/* LISP: (AUD-GET-TIMES ANY ANYNUM ANYNUM) */
LVAL putTimes(LVAL nameOrNumber, LVAL breakpoints);
/* LISP: (AUD-PUT-TIMES ANY ANY) */
#endif