Debian Codegraph @

wasm/browser/src/modules/score-handling.js

raw
1 import { freeStringPtr, string2ptr } from "../utils/string-pointers.js";
2 /*
3 csound Score Handling module from <csound.h>
4 https://csound.com/docs/api/modules.html
5 */
6
7 /**
8 * Sees whether Csound score events are performed or not,
9 * independently of real-time MIDI events
10 * @function
11 */
12 export const csoundIsScorePending = (wasm) => (csound /* CsoundInst */) =>
13 wasm.exports.csoundIsScorePending(csound);
14
15 csoundIsScorePending.toString = () => "isScorePending = async () => Number;";
16
17 /**
18 * Sets whether Csound score events are performed or not
19 * (real-time events will continue to be performed).
20 * Can be used by external software, such as a VST host,
21 * to turn off performance of score events (while continuing to perform real-time events),
22 * for example to mute a Csound score while working on other tracks of a piece,
23 * or to play the Csound instruments live.
24 * @function
25 */
26 export const csoundSetScorePending = (wasm) => (csound /* CsoundInst */, pending /* number */) =>
27 wasm.exports.csoundSetScorePending(csound, pending);
28
29 csoundSetScorePending.toString = () => "setScorePending = async (pending) => Number;";
30
31 /**
32 * Read, preprocess, and load a score from an ASCII string It can be called repeatedly,
33 * with the new score events being added to the currently scheduled ones.
34 * @function
35 */
36 export const csoundReadScore = (wasm) => (csound /* CsoundInst */, score /* string */) => {
37 const stringPtr = string2ptr(wasm, score);
38 const result = wasm.exports.csoundReadScore(csound, stringPtr);
39 freeStringPtr(wasm, stringPtr);
40 return result;
41 };
42
43 csoundReadScore.toString = () => "readScore = async (score) => Number;";
44
45 /**
46 * Returns the current score time in seconds since the beginning of performance.
47 * @function
48 */
49 export const csoundGetScoreTime = (wasm) => (csound /* CsoundInst */) =>
50 wasm.exports.csoundGetScoreTime(csound);
51
52 csoundGetScoreTime.toString = () => "getScoreTime = async () => Number;";
53
54 /**
55 * Returns the score time beginning at which score events will actually immediately be performed
56 * @function
57 */
58 export const csoundGetScoreOffsetSeconds = (wasm) => (csound /* CsoundInst */) =>
59 wasm.exports.csoundGetScoreOffsetSeconds(csound);
60
61 csoundGetScoreOffsetSeconds.toString = () => "getScoreOffsetSeconds = async () => Number;";
62
63 /**
64 * Csound score events prior to the specified time are not performed,
65 * and performance begins immediately at the specified time
66 * (real-time events will continue to be performed as they are received).
67 * Can be used by external software, such as a VST host, to begin
68 * score performance midway through a Csound score,
69 * for example to repeat a loop in a sequencer,
70 * or to synchronize other events with the Csound score.
71 * @function
72 */
73 export const csoundSetScoreOffsetSeconds = (wasm) => (csound /* CsoundInst */, time /* string */) =>
74 wasm.exports.csoundSetScoreOffsetSeconds(csound, time);
75
76 csoundSetScoreOffsetSeconds.toString = () => "setScoreOffsetSeconds = async () => Number;";
77
78 /**
79 * Rewinds a compiled Csound score to the time specified with csoundObj.setScoreOffsetSeconds().
80 * @function
81 */
82 export const csoundRewindScore = (wasm) => (csound) =>
83 wasm.exports.csoundRewindScore(csound /* CsoundInst */);
84
85 csoundRewindScore.toString = () => "rewindScore = async () => undefined;";
86
87 // PUBLIC void csoundSetCscoreCallback (CSOUND *, void(*cscoreCallback_)(CSOUND *))
88 // PUBLIC int csoundScoreSort (CSOUND *, FILE *inFile, FILE *outFile)
89 // PUBLIC int csoundScoreExtract (CSOUND *, FILE *inFile, FILE *outFile, FILE *extractFile)