MCPcopy Create free account
hub / github.com/csound/csound / start

Method start

wasm/browser/src/mains/spn.main.js:164–214  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

162 }
163
164 async start() {
165 if (!this.csoundApi) {
166 console.error("starting csound failed because csound instance wasn't created");
167 return;
168 }
169
170 if (this.currentPlayState !== "realtimePerformanceStarted") {
171 this.result = 0;
172 this.csoundApi.csoundSetOption(this.csoundInstance, "-odac");
173 this.csoundApi.csoundSetOption(this.csoundInstance, "-iadc");
174 this.csoundApi.csoundSetOption(this.csoundInstance, "--sample-rate=" + this.sampleRate);
175 this.nchnls = -1;
176 this.nchnls_i = -1;
177
178 const ksmps = this.csoundApi.csoundGetKsmps(this.csoundInstance);
179 this.ksmps = ksmps;
180 this.cnt = ksmps;
181
182 this.nchnls = this.csoundApi.csoundGetNchnls(this.csoundInstance);
183 this.nchnls_i = this.csoundApi.csoundGetNchnlsInput(this.csoundInstance);
184
185 const outputPointer = this.csoundApi.csoundGetSpout(this.csoundInstance);
186 this.csoundOutputBuffer = new Float64Array(
187 this.wasm.wasi.memory.buffer,
188 outputPointer,
189 ksmps * this.nchnls,
190 );
191
192 const inputPointer = this.csoundApi.csoundGetSpin(this.csoundInstance);
193 this.csoundInputBuffer = new Float64Array(
194 this.wasm.wasi.memory.buffer,
195 inputPointer,
196 ksmps * this.nchnls_i,
197 );
198 this.zerodBFS = this.csoundApi.csoundGet0dBFS(this.csoundInstance);
199
200 this.publicEvents.triggerOnAudioNodeCreated(this.spn);
201 this.eventPromises.createStartPromise();
202
203 const startResult = this.csoundApi.csoundStart(this.csoundInstance);
204 if (this.csoundApi._isRequestingRtMidiInput(this.csoundInstance)) {
205 requestMidi({
206 onMidiMessage: ({ data: event }) =>
207 this.csoundApi.csoundPushMidiMessage(this.csoundInstance, event[0], event[1], event[2]),
208 });
209 }
210 this.running = true;
211 await this.eventPromises.waitForStart();
212 return startResult;
213 }
214 }
215
216 async initialize({ wasmDataURI, withPlugins, autoConnect }) {
217 if (!this.plugins && withPlugins && !isEmpty(withPlugins)) {

Callers 8

loadStaticWasmFunction · 0.45
module.jsFile · 0.45
initializeMethod · 0.45
initializeMethod · 0.45
initializeMethod · 0.45
initializeMethod · 0.45
tests.jsFile · 0.45
module.jsFile · 0.45

Calls 6

requestMidiFunction · 0.90
errorMethod · 0.80
createStartPromiseMethod · 0.80
waitForStartMethod · 0.80
csoundStartMethod · 0.45

Tested by

no test coverage detected