Debian Codegraph @

wasm/browser/src/modules/general-io.js

raw
1 import { uint2String } from "../utils/text-encoders.js";
2 import { trimNull } from "../utils/trim-null.js";
3
4 /*
5 csound general i/o module from <csound.h>
6 https://csound.com/docs/api/modules.html
7 */
8
9 /**
10 * Returns the audio output name (-o)
11 * @function
12 * @name getOutputName
13 * @memberof CsoundObj
14 * @return {Promise.<string>}
15 */
16 export const csoundGetOutputName = (wasm) => (csound) => {
17 const { buffer } = wasm.wasi.memory;
18 const ptr = wasm.exports.csoundGetOutputName(csound);
19 const stringBuffer = new Uint8Array(buffer, ptr, 64);
20 return trimNull(uint2String(stringBuffer)) || "";
21 };
22
23 csoundGetOutputName.toString = () => "getOutputName = async () => String;";
24
25 /**
26 * Returns the audio input name (-i)
27 * @function
28 * @name getInputName
29 * @memberof CsoundObj
30 * @return {Promise.<string>}
31 */
32 export const csoundGetInputName = (wasm) => (csound) => {
33 const { buffer } = wasm.wasi.memory;
34 const ptr = wasm.exports.csoundGetInputName(csound);
35 const stringBuffer = new Uint8Array(buffer, ptr, 64);
36 return trimNull(uint2String(stringBuffer)) || "";
37 };
38
39 csoundGetInputName.toString = () => "getInputName = async (csound) => String;";
40
41 // PUBLIC void csoundSetOutput (CSOUND *csound, const char *name, const char *type, const char *format)
42 // PUBLIC void csoundGetOutputFormat (CSOUND *csound, char *type, char *format)
43 // PUBLIC void csoundSetInput (CSOUND *csound, const char *name)
44 // PUBLIC void csoundSetMIDIInput (CSOUND *csound, const char *name)
45 // PUBLIC void csoundSetMIDIFileInput (CSOUND *csound, const char *name)
46 // PUBLIC void csoundSetMIDIOutput (CSOUND *csound, const char *name)
47 // PUBLIC void csoundSetMIDIFileOutput (CSOUND *csound, const char *name)
48 // PUBLIC void csoundSetFileOpenCallback (CSOUND *p, void(*func)(CSOUND *, const char *, int, int, int))