@@ -84,7 +84,7 @@ static const char* samplerPlugin(bool useDisk)
84
84
85
85
Engine::Engine (Options inOptions)
86
86
: m_engine(nullptr )
87
- , m_useDisk(Methcla::Version::isPro() )
87
+ , m_useDisk(true )
88
88
{
89
89
Methcla::EngineOptions options (inOptions.engineOptions );
90
90
options.audioDriver .bufferSize = 256 ;
@@ -148,7 +148,7 @@ void Engine::useDisk(bool flag)
148
148
}
149
149
}
150
150
151
- static Methcla_Time kLatency = 0.001 ;
151
+ static Methcla_Time kLatency = 0.003 ;
152
152
153
153
static float mapRate (float value)
154
154
{
@@ -174,12 +174,14 @@ void Engine::startVoice(VoiceId voice, size_t soundIndex, float amp, float rate)
174
174
const Methcla::SynthId synth = request.synth (
175
175
samplerPlugin (m_useDisk),
176
176
m_voiceGroup,
177
- { amp, rate },
177
+ { 1 , 48000 ./ 44100 . },
178
178
{ Methcla::Value (sound.path ())
179
179
, Methcla::Value (false ) }
180
180
);
181
181
request.mapOutput (synth, 0 , bus1);
182
182
request.mapOutput (synth, 1 , bus2);
183
+ // request.mapOutput(synth, 0, Methcla::AudioBusId(0), Methcla::kBusMappingExternal);
184
+ // request.mapOutput(synth, 1, Methcla::AudioBusId(1), Methcla::kBusMappingExternal);
183
185
184
186
// Envelope options
185
187
const std::list<Methcla::Value> envOptions =
@@ -189,12 +191,14 @@ void Engine::startVoice(VoiceId voice, size_t soundIndex, float amp, float rate)
189
191
, Methcla::Value (1 .5f )
190
192
};
191
193
192
- auto envelope1 = request.synth (METHCLA_PLUGINS_ASR_ENVELOPE_URI, m_voiceGroup, {}, envOptions);
194
+ // auto envelope1 = request.synth(METHCLA_PLUGINS_ASR_ENVELOPE_URI, m_voiceGroup, {}, envOptions);
195
+ auto envelope1 = request.synth (METHCLA_PLUGINS_PATCH_CABLE_URI, m_voiceGroup, {});
193
196
request.mapInput (envelope1, 0 , bus1);
194
197
request.mapOutput (envelope1, 0 , Methcla::AudioBusId (0 ), Methcla::kBusMappingExternal );
195
198
request.whenDone (envelope1, Methcla::kNodeDoneFreeSelf |Methcla::kNodeDoneFreePreceeding );
196
199
197
- auto envelope2 = request.synth (METHCLA_PLUGINS_ASR_ENVELOPE_URI, m_voiceGroup, {}, envOptions);
200
+ // auto envelope2 = request.synth(METHCLA_PLUGINS_ASR_ENVELOPE_URI, m_voiceGroup, {}, envOptions);
201
+ auto envelope2 = request.synth (METHCLA_PLUGINS_PATCH_CABLE_URI, m_voiceGroup, {});
198
202
request.mapInput (envelope2, 0 , bus2);
199
203
request.mapOutput (envelope2, 0 , Methcla::AudioBusId (1 ), Methcla::kBusMappingExternal );
200
204
request.whenDone (envelope2, Methcla::kNodeDoneFreeSelf );
@@ -207,14 +211,14 @@ void Engine::startVoice(VoiceId voice, size_t soundIndex, float amp, float rate)
207
211
request.closeBundle ();
208
212
209
213
m_engine->addNotificationHandler (m_engine->freeNodeIdHandler (synth));
210
- m_engine->addNotificationHandler (m_engine->freeNodeIdHandler (envelope1));
211
- m_engine->addNotificationHandler (m_engine->freeNodeIdHandler (envelope2, [this ,bus1,bus2](Methcla::NodeId){
212
- m_engine->audioBusId ().free (bus1);
213
- m_engine->audioBusId ().free (bus2);
214
- }));
214
+ // m_engine->addNotificationHandler(m_engine->freeNodeIdHandler(envelope1));
215
+ // m_engine->addNotificationHandler(m_engine->freeNodeIdHandler(envelope2, [this,bus1,bus2](Methcla::NodeId){
216
+ // m_engine->audioBusId().free(bus1);
217
+ // m_engine->audioBusId().free(bus2);
218
+ // }));
215
219
216
220
request.send ();
217
- // m_voices[voice] = synth;
221
+ m_voices[voice] = synth;
218
222
// std::cout << "Synth " << synth.id()
219
223
// << sound.path()
220
224
// << " duration=" << sound.duration()
@@ -238,13 +242,13 @@ void Engine::updateVoice(VoiceId voice, float amp, float rate)
238
242
239
243
void Engine::stopVoice (VoiceId voice)
240
244
{
241
- // auto it = m_voices.find(voice);
242
- // if (it != m_voices.end()) {
243
- // Methcla::Request request(engine());
244
- // request.openBundle(engine().currentTime() + kLatency);
245
- // request.free(it->second);
246
- // request.closeBundle();
247
- // // request.send();
248
- // m_voices.erase(it);
249
- // }
245
+ auto it = m_voices.find (voice);
246
+ if (it != m_voices.end ()) {
247
+ Methcla::Request request (engine ());
248
+ request.openBundle (engine ().currentTime () + kLatency );
249
+ request.free (it->second );
250
+ request.closeBundle ();
251
+ request.send ();
252
+ m_voices.erase (it);
253
+ }
250
254
}
0 commit comments