private IEnumerator SamplerCoroutine() { //Create Sampler module: SunVox.sv_lock_slot(0); int mod_num = SunVox.sv_new_module(0, "Sampler", "Sampler", 0, 0, 0); SunVox.sv_unlock_slot(0); if (mod_num >= 0) { log("New module created: " + mod_num); //Connect the new module to the Main Output: SunVox.sv_lock_slot(0); SunVox.sv_connect_module(0, mod_num, 0); SunVox.sv_unlock_slot(0); //Load a sample: var path = "Assets/StreamingAssets/flute.xi"; // This path is correct only for standalone SunVox.sv_sampler_load(0, mod_num, path, -1); //Send Note ON: log("Note ON"); SunVox.sv_send_event(0, 0, 64, 128, mod_num + 1, 0, 0); yield return(new WaitForSeconds(1)); //Send Note OFF: log("Note OFF"); SunVox.sv_send_event(0, 0, 128, 128, mod_num + 1, 0, 0); yield return(new WaitForSeconds(1)); } else { log("Can't create the new module"); } }
private IEnumerator ModuleCoroutine() { //Create Generator module: SunVox.sv_lock_slot(0); int mod_num = SunVox.sv_new_module(0, "Generator", "Generator", 0, 0, 0); SunVox.sv_unlock_slot(0); if (mod_num >= 0) { log("New module created: " + mod_num); //Connect the new module to the Main Output: SunVox.sv_lock_slot(0); SunVox.sv_connect_module(0, mod_num, 0); SunVox.sv_unlock_slot(0); //Send Note ON: log("Note ON"); SunVox.sv_send_event(0, 0, 64, 128, mod_num + 1, 0, 0); yield return(new WaitForSeconds(1)); //Send Note OFF: log("Note OFF"); SunVox.sv_send_event(0, 0, 128, 128, mod_num + 1, 0, 0); yield return(new WaitForSeconds(1)); } else { log("Can't create the new module"); } //Load module and play it: log("Load module and play it"); loadBinaryAsset(getDataPath("organ.sunsynth"), onBinaryFileLoaded); yield return(new WaitForSeconds(1)); }
private IEnumerator SamplerCoroutine() { //Create Sampler module: SunVox.sv_lock_slot(0); int mod_num = SunVox.sv_new_module(0, "Sampler", "Sampler", 0, 0, 0); SunVox.sv_unlock_slot(0); if (mod_num >= 0) { log("New module created: " + mod_num); //Connect the new module to the Main Output: SunVox.sv_lock_slot(0); SunVox.sv_connect_module(0, mod_num, 0); SunVox.sv_unlock_slot(0); //Load a sample: log("Load sample and play it"); loadBinaryAsset(getDataPath("flute.xi"), () => StartCoroutine(onBinaryFileLoadedCoroutine(mod_num))); yield return(new WaitForSeconds(1)); } else { log("Can't create the new module"); } }
private IEnumerator ModuleCoroutine() { //Create Generator module: SunVox.sv_lock_slot(0); int mod_num = SunVox.sv_new_module(0, "Generator", "Generator", 0, 0, 0); SunVox.sv_unlock_slot(0); if (mod_num >= 0) { log("New module created: " + mod_num); //Connect the new module to the Main Output: SunVox.sv_lock_slot(0); SunVox.sv_connect_module(0, mod_num, 0); SunVox.sv_unlock_slot(0); //Send Note ON: log("Note ON"); SunVox.sv_send_event(0, 0, 64, 128, mod_num + 1, 0, 0); yield return(new WaitForSeconds(1)); //Send Note OFF: log("Note OFF"); SunVox.sv_send_event(0, 0, 128, 128, mod_num + 1, 0, 0); yield return(new WaitForSeconds(1)); } else { log("Can't create the new module"); } //Load module and play it: var path = "Assets/StreamingAssets/organ.sunsynth"; // This path is correct only for standalone int mod_num2 = SunVox.sv_load_module(0, path, 0, 0, 0); if (mod_num2 >= 0) { log("Module loaded: " + mod_num2); //Connect the new module to the Main Output: SunVox.sv_lock_slot(0); SunVox.sv_connect_module(0, mod_num2, 0); SunVox.sv_unlock_slot(0); //Send Note ON: log("Note ON"); SunVox.sv_send_event(0, 0, 64, 128, mod_num2 + 1, 0, 0); yield return(new WaitForSeconds(1)); //Send Note OFF: log("Note OFF"); SunVox.sv_send_event(0, 0, 128, 128, mod_num2 + 1, 0, 0); yield return(new WaitForSeconds(1)); } else { log("Can't load the module"); } }
private IEnumerator playModuleCoroutine(int mod_num2) { log("Module loaded: " + mod_num2); //Connect the new module to the Main Output: SunVox.sv_lock_slot(0); SunVox.sv_connect_module(0, mod_num2, 0); SunVox.sv_unlock_slot(0); //Send Note ON: log("Note ON"); SunVox.sv_send_event(0, 0, 64, 128, mod_num2 + 1, 0, 0); yield return(new WaitForSeconds(1)); //Send Note OFF: log("Note OFF"); SunVox.sv_send_event(0, 0, 128, 128, mod_num2 + 1, 0, 0); }
public int LoadFxInstrument(string instrument) { var path = GetDataPath(instrument); // var path = $"Assets/StreamingAssets/{instrument}"; int moduleId = SunVox.sv_load_module((int)Slot.FX, path, 0, 0, 0); if (moduleId >= 0) { Logger.LogTraceFormat("Instrument {0} loaded as module #{1}", Category.SunVox, instrument, moduleId); //Connect the new module to the Main Output: SunVox.sv_lock_slot((int)Slot.FX); SunVox.sv_connect_module((int)Slot.FX, moduleId, 0); SunVox.sv_unlock_slot((int)Slot.FX); } else { Logger.LogWarning($"Can't load instrument {path}", Category.SunVox); } return(moduleId); }