MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / getAudio

Method getAudio

extlibs/soloud/src/audiosource/speech/soloud_speech.cpp:55–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53 }
54
55 unsigned int SpeechInstance::getAudio(float *aBuffer, unsigned int aSamplesToRead, unsigned int aBufferSize)
56 {
57 mSynth.init(mParent->mBaseFrequency, mParent->mBaseSpeed, mParent->mBaseDeclination, mParent->mBaseWaveform);
58 unsigned int samples_out = 0;
59 if (mSampleCount > mOffset)
60 {
61 unsigned int copycount = mSampleCount - mOffset;
62 if (copycount > aSamplesToRead)
63 {
64 copycount = aSamplesToRead;
65 }
66 writesamples(mSample + mOffset, aBuffer, copycount);
67 mOffset += copycount;
68 samples_out += copycount;
69 }
70
71 while (mSampleCount >= 0 && samples_out < aSamplesToRead)
72 {
73 mOffset = 0;
74 mSampleCount = mSynth.synth(mSynth.mNspFr, mSample);
75 if (mSampleCount > 0)
76 {
77 unsigned int copycount = mSampleCount;
78 if (copycount > aSamplesToRead - samples_out)
79 {
80 copycount = aSamplesToRead - samples_out;
81 }
82 writesamples(mSample, aBuffer + samples_out, copycount);
83 mOffset += copycount;
84 samples_out += copycount;
85 }
86 }
87 return samples_out;
88 }
89
90 result SpeechInstance::rewind()
91 {

Callers

nothing calls this directly

Calls 3

writesamplesFunction · 0.85
synthMethod · 0.80
initMethod · 0.45

Tested by

no test coverage detected