| 1 |
import { |
| 2 |
csoundCreate, |
| 3 |
csoundDestroy, |
| 4 |
csoundGetAPIVersion, |
| 5 |
csoundGetVersion, |
| 6 |
csoundInitialize, |
| 7 |
} from "./modules/instantiation"; |
| 8 |
import { |
| 9 |
csoundParseOrc, |
| 10 |
csoundCompileTree, |
| 11 |
csoundCompileOrc, |
| 12 |
csoundEvalCode, |
| 13 |
csoundStart, |
| 14 |
csoundCompileCsd, |
| 15 |
csoundCompileCsdText, |
| 16 |
csoundPerform, |
| 17 |
csoundPerformKsmps, |
| 18 |
csoundPerformBuffer, |
| 19 |
csoundStop, |
| 20 |
csoundCleanup, |
| 21 |
csoundReset, |
| 22 |
} from "./modules/performance"; |
| 23 |
import { |
| 24 |
csoundGetSr, |
| 25 |
csoundGetKr, |
| 26 |
csoundGetKsmps, |
| 27 |
csoundGetNchnls, |
| 28 |
csoundGetNchnlsInput, |
| 29 |
csoundGet0dBFS, |
| 30 |
csoundGetA4, |
| 31 |
csoundGetCurrentTimeSamples, |
| 32 |
csoundGetSizeOfMYFLT, |
| 33 |
csoundSetOption, |
| 34 |
csoundSetParams as csoundSetParameters, |
| 35 |
csoundGetParams as csoundGetParameters, |
| 36 |
csoundGetDebug, |
| 37 |
csoundSetDebug, |
| 38 |
} from "./modules/attributes"; |
| 39 |
import { |
| 40 |
csoundGetInputBufferSize, |
| 41 |
csoundGetOutputBufferSize, |
| 42 |
csoundGetInputBuffer, |
| 43 |
csoundGetOutputBuffer, |
| 44 |
csoundGetSpin, |
| 45 |
csoundGetSpout, |
| 46 |
} from "./modules/rtaudio"; |
| 47 |
import { |
| 48 |
csoundGetMIDIDevList as csoundGetMIDIDevelopmentList, |
| 49 |
csoundSetMidiCallbacks, |
| 50 |
csoundGetRtMidiName, |
| 51 |
csoundGetMidiOutFileName, |
| 52 |
csoundPushMidiMessage, |
| 53 |
_isRequestingRtMidiInput, |
| 54 |
} from "./modules/rtmidi"; |
| 55 |
import { |
| 56 |
csoundInputMessage, |
| 57 |
csoundInputMessageAsync, |
| 58 |
csoundGetControlChannel, |
| 59 |
csoundSetControlChannel, |
| 60 |
csoundGetStringChannel, |
| 61 |
csoundSetStringChannel, |
| 62 |
} from "./modules/control-events"; |
| 63 |
import { csoundGetInputName, csoundGetOutputName } from "./modules/general-io"; |
| 64 |
import { csoundAppendEnv as csoundAppendEnvironment, csoundShouldDaemonize } from "./modules/extra"; |
| 65 |
import { |
| 66 |
csoundIsScorePending, |
| 67 |
csoundSetScorePending, |
| 68 |
csoundReadScore, |
| 69 |
csoundGetScoreTime, |
| 70 |
csoundGetScoreOffsetSeconds, |
| 71 |
csoundSetScoreOffsetSeconds, |
| 72 |
csoundRewindScore, |
| 73 |
} from "./modules/score-handling"; |
| 74 |
import { |
| 75 |
csoundTableLength, |
| 76 |
csoundTableGet, |
| 77 |
csoundTableSet, |
| 78 |
csoundTableCopyIn, |
| 79 |
csoundTableCopyOut, |
| 80 |
csoundGetTable, |
| 81 |
csoundGetTableArgs as csoundGetTableArguments, |
| 82 |
csoundIsNamedGEN, |
| 83 |
csoundGetNamedGEN, |
| 84 |
} from "./modules/table"; |
| 85 |
import * as fs from "./filesystem/worker-fs"; |
| 86 |
|
| 87 |
import { assoc, dissoc, keys, mergeAll, reduce } from "rambda/dist/rambda.esm.js"; |
| 88 |
|
| 89 |
goog.declareModuleId("libcsound"); |
| 90 |
|
| 91 |
/* |
| 92 |
Don't call these functions directly. |
| 93 |
They are closures that take wasm instance as |
| 94 |
first argument before they can be called as |
| 95 |
documented. |
| 96 |
*/ |
| 97 |
export const api = { |
| 98 |
// @module/instantiation |
| 99 |
csoundCreate, |
| 100 |
csoundDestroy, |
| 101 |
csoundGetAPIVersion, |
| 102 |
csoundGetVersion, |
| 103 |
csoundInitialize, |
| 104 |
// @module/performance |
| 105 |
csoundParseOrc, |
| 106 |
csoundCompileTree, |
| 107 |
csoundCompileOrc, |
| 108 |
csoundEvalCode, |
| 109 |
csoundStart, |
| 110 |
csoundCompileCsd, |
| 111 |
csoundCompileCsdText, |
| 112 |
csoundPerform, |
| 113 |
csoundPerformKsmps, |
| 114 |
csoundPerformBuffer, |
| 115 |
csoundStop, |
| 116 |
csoundCleanup, |
| 117 |
csoundReset, |
| 118 |
// @module/attributes |
| 119 |
csoundGetSr, |
| 120 |
csoundGetKr, |
| 121 |
csoundGetKsmps, |
| 122 |
csoundGetNchnls, |
| 123 |
csoundGetNchnlsInput, |
| 124 |
csoundGet0dBFS, |
| 125 |
csoundGetA4, |
| 126 |
csoundGetCurrentTimeSamples, |
| 127 |
csoundGetSizeOfMYFLT, |
| 128 |
csoundSetOption, |
| 129 |
csoundSetParams: csoundSetParameters, |
| 130 |
csoundGetParams: csoundGetParameters, |
| 131 |
csoundGetDebug, |
| 132 |
csoundSetDebug, |
| 133 |
// @module/rtaudio |
| 134 |
csoundGetInputBufferSize, |
| 135 |
csoundGetOutputBufferSize, |
| 136 |
csoundGetInputBuffer, |
| 137 |
csoundGetOutputBuffer, |
| 138 |
csoundGetSpin, |
| 139 |
csoundGetSpout, |
| 140 |
// @module/rtmidi |
| 141 |
csoundGetMIDIDevList: csoundGetMIDIDevelopmentList, |
| 142 |
csoundSetMidiCallbacks, |
| 143 |
csoundGetRtMidiName, |
| 144 |
csoundGetMidiOutFileName, |
| 145 |
csoundPushMidiMessage, |
| 146 |
_isRequestingRtMidiInput, |
| 147 |
// @module/control_events |
| 148 |
csoundInputMessage, |
| 149 |
csoundInputMessageAsync, |
| 150 |
csoundGetControlChannel, |
| 151 |
csoundSetControlChannel, |
| 152 |
csoundGetStringChannel, |
| 153 |
csoundSetStringChannel, |
| 154 |
// @module/general_io |
| 155 |
csoundGetInputName, |
| 156 |
csoundGetOutputName, |
| 157 |
// @module/extra |
| 158 |
csoundAppendEnv: csoundAppendEnvironment, |
| 159 |
csoundShouldDaemonize, |
| 160 |
// @module/score-handling |
| 161 |
csoundIsScorePending, |
| 162 |
csoundSetScorePending, |
| 163 |
csoundReadScore, |
| 164 |
csoundGetScoreTime, |
| 165 |
csoundGetScoreOffsetSeconds, |
| 166 |
csoundSetScoreOffsetSeconds, |
| 167 |
csoundRewindScore, |
| 168 |
// @module/table |
| 169 |
csoundTableLength, |
| 170 |
csoundTableGet, |
| 171 |
csoundTableSet, |
| 172 |
csoundTableCopyIn, |
| 173 |
csoundTableCopyOut, |
| 174 |
csoundGetTable, |
| 175 |
csoundGetTableArgs: csoundGetTableArguments, |
| 176 |
csoundIsNamedGEN, |
| 177 |
csoundGetNamedGEN, |
| 178 |
// filesystem |
| 179 |
fs, |
| 180 |
}; |
| 181 |
|
| 182 |
export default function (wasm) { |
| 183 |
return mergeAll([ |
| 184 |
reduce((accumulator, k) => assoc(k, api[k](wasm), accumulator), {}, keys(dissoc("fs")(api))), |
| 185 |
reduce((accumulator, k) => assoc(k, api.fs[k](wasm), accumulator), {}, keys(fs)), |
| 186 |
]); |
| 187 |
} |