// Start is called before the first frame update void Start() { csound = this.GetComponent <CsoundUnity>(); var opcodeList = csound.GetOpcodeList(); var count = 0; foreach (var opcode in opcodeList) { var types = ""; foreach (var argumentType in opcode.Value) { types += "[<color=blue>in: </color>" + argumentType.intypes + "] [<color=red>out: </color>" + argumentType.outypes + "] [<color=purple>flags: </color>" + argumentType.flags + "] "; } Debug.Log($"[{count}] [<b>{opcode.Key}</b>] {types}"); count++; } var namedGens = csound.GetNamedGens(); Debug.Log($"<b>NAMED GENS: {namedGens.Count}</b>"); foreach (var gen in namedGens) { Debug.Log($"<b>{gen.Key}</b>: {gen.Value}"); } Debug.Log("<b>CSOUND ENVIRONMENT</b>: \n<b>OPCODE6DIR64:</b> " + csound.GetEnv(CsoundUnity.EnvType.OPCODE6DIR64) + "\n<b>SADIR:</b> " + csound.GetEnv(CsoundUnity.EnvType.SADIR) + "\n<b>SSDIR:</b> " + csound.GetEnv(CsoundUnity.EnvType.SSDIR) + "\n<b>SFDIR:</b> " + csound.GetEnv(CsoundUnity.EnvType.SFDIR)); }
void OnEnable() { csoundUnity = (CsoundUnity)target; m_csoundFileName = this.serializedObject.FindProperty("_csoundFileName"); m_csoundAsset = this.serializedObject.FindProperty("_csoundAsset"); m_csoundFileGUID = this.serializedObject.FindProperty("_csoundFileGUID"); m_csoundString = this.serializedObject.FindProperty("_csoundString"); m_csoundScore = this.serializedObject.FindProperty("csoundScore"); m_processAudio = this.serializedObject.FindProperty("processClipAudio"); m_mute = this.serializedObject.FindProperty("mute"); m_logCsoundOutput = this.serializedObject.FindProperty("logCsoundOutput"); m_loudVolumeWarning = this.serializedObject.FindProperty("loudVolumeWarning"); m_loudWarningThreshold = this.serializedObject.FindProperty("loudWarningThreshold"); m_channelControllers = this.serializedObject.FindProperty("_channels"); m_availableAudioChannels = this.serializedObject.FindProperty("_availableAudioChannels"); m_drawCsoundString = this.serializedObject.FindProperty("_drawCsoundString"); m_drawTestScore = this.serializedObject.FindProperty("_drawTestScore"); m_drawSettings = this.serializedObject.FindProperty("_drawSettings"); m_drawChannels = this.serializedObject.FindProperty("_drawChannels"); m_drawAudioChannels = this.serializedObject.FindProperty("_drawAudioChannels"); //if (m_csoundFileName.stringValue.Length > 4) //{ // Debug.Log($"csoundFile is {m_csoundFileName.stringValue} (guid {m_csoundFileGUID.stringValue}), has channels size: {m_channelControllers.arraySize} csoundString: \n{m_csoundString.stringValue}"); //} }
// private uint ksmpsIndex = 0; #endregion PRIVATE_FIELDS private void Awake() { if (csoundUnityGameObject) { csoundUnity = csoundUnityGameObject.GetComponent <CsoundUnity>(); if (!csoundUnity) { Debug.LogError("CsoundUnity was not found?"); } } AudioSettings.GetDSPBufferSize(out bufferSize, out numBuffers); audioSource = GetComponent <AudioSource>(); if (!audioSource) { Debug.LogError("AudioSource was not found?"); } audioSource.velocityUpdateMode = AudioVelocityUpdateMode.Fixed; audioSource.spatialBlend = 1.0f; if (selectedAudioChannelIndexByChannel == null) { selectedAudioChannelIndexByChannel = new int[2]; } // TODO: force doppler level of the AudioSource to 0, to avoid audio artefacts ? // audioSource.dopplerLevel = 0; }
// Use this for initialization void Start() { myRB = GetComponent <Rigidbody2D>(); myAnim = GetComponent <Animator>(); csound = GetComponent <CsoundUnity>(); wheelVar = 0; drumVar = 0; platformVar = 0; }
IEnumerator Start() { isInitialized = false; // wait for csound to be initialized while (!csoundUnity.IsInitialized) { yield return(null); } csoundUnity.SetChannel("BPM", BPM); var count = 0; foreach (var clip in clips) { var name = "Samples/" + clip.name; Debug.Log("loading clip " + name); var samples = CsoundUnity.GetSamples(name, CsoundUnity.SamplesOrigin.Resources); Debug.Log("samples read: " + samples.Length); if (samples.Length > 0) { var nChan = clip.channels; var tn = 900 + count; var res = csoundUnity.CreateTable(tn, samples); //Debug.Log($"creating table: sampletable{tn}"); csoundUnity.SetChannel($"sampletable{tn}", tn); Debug.Log(res == 0 ? $"<color=green>Table {tn} created, set channel sampletable{tn} = {tn} </color>" : $"<color=red>Error: Couldn't create Table {tn} </color>"); count++; } yield return(new WaitForEndOfFrame()); } if (showSequencerGUI) { pads = new GameObject[numpads]; for (int voice = 0; voice < numberOfVoices; voice++) { for (int beat = 0; beat < numberOfBeats; beat++) { GameObject gObj = GameObject.CreatePrimitive(PrimitiveType.Cube); gObj.transform.position = new Vector3(beat - numberOfBeats + 8f, numberOfVoices - voice - 4f, 0); gObj.transform.localScale = new Vector3(0.5f, 0.5f, 0.1f); double enabled = csoundUnity.GetTableSample(voice + 1, beat); gObj.GetComponent <Renderer>().material.color = (enabled == 1 ? new Color(1, 0, 0) : new Color(.5f, .5f, .5f)); gObj.AddComponent <PadController>(); gObj.name = padIndex++.ToString(); pads[beat + (voice * numberOfBeats)] = gObj; } } } //padScale = pads[0].transform.localScale; isInitialized = true; Debug.Log("start end!"); }
void Awake() { //assign CsoundUnity component csoundUnity = GetComponent <CsoundUnity>(); if (!csoundUnity) { Debug.LogError("Can't find CsoundUnity"); } }
private void Awake() { csound = GetComponent <CsoundUnity>(); freqMinValue.text = frequencySlider.minValue.ToString(); freqMaxValue.text = frequencySlider.maxValue.ToString(); ampMinValue.text = ampSlider.minValue.ToString(); ampMaxValue.text = ampSlider.maxValue.ToString(); }
void OnEnable() { csoundUnity = (CsoundUnity)target; channelControllers = new List <CsoundChannelController>(); controllerValues = new List <float>(); //parse Csound files for CsoundUnity descriptor if (csoundUnity.csoundFile.Length > 4) { //deals with Csound files found the CsoundFiles folder string dir = Application.dataPath + "/Scripts/CsoundFiles"; if (Directory.Exists(dir)) { parseCsdFile(dir + "/" + csoundUnity.csoundFile); } else { parseCsdFile(Application.dataPath + "Scripts/" + csoundUnity.csoundFile); } } }
// Start is called before the first frame update void Start() { csoundUnity = GameObject.Find("CsoundUnity").GetComponent <CsoundUnity>(); if (!csoundUnity) { Debug.LogError("Can't find CsoundUnity?"); } var name = "Samples/" + audioClip.name; var samplesStereo = CsoundUnity.GetSamples(name, CsoundUnity.SamplesOrigin.Resources, 1, true); var samplesMono = CsoundUnity.GetSamples(name, CsoundUnity.SamplesOrigin.Resources, 1, false); if (csoundUnity.CreateTable(9000, samplesStereo) == -1) { Debug.LogError("Couldn't create table"); } if (csoundUnity.CreateTable(9001, samplesMono) == -1) { Debug.LogError("Couldn't create table"); } }
void Start() { // Retrieves and initialises the Csound component #region CSound Initialisation csoundUnity = GetComponent <CsoundUnity>(); #endregion // Calculate frequencies relative to bottom c #region Delta Frequencies deltaCC = (c - c); deltaCSC = (cs - c); deltaDC = (d - c); deltaEFC = (ef - c); deltaEC = (e - c); deltaFC = (f - c); deltaFSC = (fs - c); deltaGC = (g - c); deltaGSC = (gs - c); deltaAC = (a - c); deltaBFC = (bf - c); deltaBC = (b - c); #endregion // Initialise Csound channels #region Channels csoundUnity.setChannel("temp", baseTemp); csoundUnity.setChannel("osc", baseToggle); csoundUnity.setChannel("sin1", baseToggle); csoundUnity.setChannel("sin2", baseToggle); csoundUnity.setChannel("sin3", baseToggle); csoundUnity.setChannel("sin4", baseToggle); csoundUnity.setChannel("sin1Ampl", baseAmpl); csoundUnity.setChannel("sin2Ampl", baseAmpl); csoundUnity.setChannel("sin3Ampl", baseAmpl); csoundUnity.setChannel("sin4Ampl", baseAmpl); csoundUnity.setChannel("sin1Freq", baseFreq); csoundUnity.setChannel("sin2Freq", baseFreq); csoundUnity.setChannel("sin3Freq", baseFreq); csoundUnity.setChannel("sin4Freq", baseFreq); csoundUnity.setChannel("att", baseAtt); csoundUnity.setChannel("dec", baseDec); csoundUnity.setChannel("sus", baseSus); csoundUnity.setChannel("rel", baseRel); #endregion // Initialise oscillator values #region Sine Osc 1 sin1Active = baseToggle; sin1Frequency = baseFreq; sin1Amplitude = baseAmpl; #endregion #region Sine Osc 2 sin2Active = baseToggle; sin2Frequency = baseFreq; sin2Amplitude = baseAmpl; #endregion #region Sine Osc 3 sin3Active = baseToggle; sin3Frequency = baseFreq; sin3Amplitude = baseAmpl; #endregion #region Sine Osc 4 sin4Active = baseToggle; sin4Frequency = baseFreq; sin4Amplitude = baseAmpl; #endregion // Initialise Envelope values #region Envelope attack = baseAtt; decay = baseDec; sustain = baseSus; release = baseRel; #endregion // Initialise master values #region Master masterActive = baseToggle; instrumentActive = true; tempo = baseTemp; octave = baseOctave; #endregion }
private void Awake() { csoundUnity = GetComponent <CsoundUnity>(); //Create A singleton instance = this; }
// Use this for initialization void Start() { csound = GetComponent <CsoundUnity>(); csound.setChannel("tempo", tempo); }
public void Init(CsoundUnity csound) { this.csoundUnity = csound; this.csoundUnityGameObject = csound.gameObject; zerodbfs = csoundUnity.Get0dbfs(); }