/// <summary> /// Loads our instrument set data /// </summary> /// <param name="pathIN"></param> /// <returns></returns> public static IEnumerator LoadData(string pathIN, System.Action <InstrumentSetData> callback) { string data = null; yield return(MusicHelpers.GetUWR(MusicFileConfig.mSavesPath + "/" + pathIN + "/InstrumentSetData.txt", (x) => { data = x.downloadHandler.text; })); InstrumentSetData saveOUT = JsonUtility.FromJson <InstrumentSetData>(data); // Version check and update. if (saveOUT.mVersion == 0.0f) { string generatorData = null; yield return(MusicHelpers.GetUWR("/MusicGenerator/InstrumentSaves/" + pathIN + "/generator.txt", (x) => { generatorData = x.downloadHandler.text; })); GeneratorSave generatorSave = JsonUtility.FromJson <GeneratorSave>(generatorData); /// we need to grab these from the generatorSave as the variables belonged to that in the last version saveOUT = new InstrumentSetData(); saveOUT.Tempo = generatorSave.mTempo; saveOUT.RepeatMeasuresNum = generatorSave.mRepeatMeasuresNum; saveOUT.mProgressionRate = (eProgressionRate)generatorSave.mProgressionRate; saveOUT.mTimeSignature = generatorSave.mTimeSignature; } callback(saveOUT); yield return(null); }
/// <summary> /// Loads chord progression data from JSON /// </summary> /// <param name="pathIN"></param> /// <returns></returns> public static IEnumerator LoadData(string pathIN, System.Action <ChordProgressionData> callback) { string data = null; yield return(MusicHelpers.GetUWR("/MusicGenerator/InstrumentSaves/" + pathIN + "/ChordProgressionData.txt", (x) => { data = x.downloadHandler.text; })); ChordProgressionData saveOUT = JsonUtility.FromJson <ChordProgressionData>(data); if (saveOUT.mVersion == 0.0f) { string generatorData = null; yield return(MusicHelpers.GetUWR("/MusicGenerator/InstrumentSaves/" + pathIN + "/generator.txt", (x) => { generatorData = x.downloadHandler.text; })); GeneratorSave generatorSave = JsonUtility.FromJson <GeneratorSave>(generatorData); /// we need to grab these from the generatorSave as the variables belonged to that in the last version saveOUT = new ChordProgressionData(); saveOUT.DominantInfluence = generatorSave.mDominantInfluence; saveOUT.mExcludedProgSteps = generatorSave.mExcludedProgSteps.ToArray(); saveOUT.SubdominantInfluence = generatorSave.mSubdominantInfluence; saveOUT.TonicInfluence = generatorSave.mTonicInfluence; saveOUT.TritoneSubInfluence = generatorSave.mTritoneSubInfluence; } callback(saveOUT); yield return(null); }
private static InstrumentSetData UpdateVersion(string pathIN, InstrumentSetData save) { if (save == null || save.mVersion == 0.0f) { string generatorPath = MusicFileConfig.GetConfigDirectory(pathIN) + "/generator.txt"; /// we need to grab these from the generatorSave as the variables belonged to that in the last version if (File.Exists(generatorPath)) { GeneratorSave generatorSave = JsonUtility.FromJson <GeneratorSave>(File.ReadAllText(generatorPath)); save = new InstrumentSetData(); save.Tempo = generatorSave.mTempo; save.RepeatMeasuresNum = generatorSave.mRepeatMeasuresNum; save.mProgressionRate = (eProgressionRate)generatorSave.mProgressionRate; save.mTimeSignature = generatorSave.mTimeSignature; } } return(save); }
/// <summary> /// Updates save type and variables for new generator versions. /// </summary> /// <param name="pathIN"></param> /// <param name="saveOUT"></param> /// <returns></returns> private static ChordProgressionData UpdateVersion(string pathIN, ChordProgressionData saveOUT) { if (saveOUT == null || saveOUT.mVersion == 0.0f) { string generatorPath = MusicFileConfig.GetConfigDirectory(pathIN) + "/generator.txt"; /// we need to grab these from the generatorSave as the variables belonged to that in the last version if (File.Exists(generatorPath)) { GeneratorSave generatorSave = JsonUtility.FromJson <GeneratorSave>(File.ReadAllText(generatorPath)); saveOUT = new ChordProgressionData(); saveOUT.DominantInfluence = generatorSave.mDominantInfluence; saveOUT.mExcludedProgSteps = generatorSave.mExcludedProgSteps.ToArray(); saveOUT.SubdominantInfluence = generatorSave.mSubdominantInfluence; saveOUT.TonicInfluence = generatorSave.mTonicInfluence; saveOUT.TritoneSubInfluence = generatorSave.mTritoneSubInfluence; } } return(saveOUT); }
private static MusicGeneratorData UpdateVersion(string data, string pathIN, MusicGeneratorData save) { GeneratorSave generatorSave = JsonUtility.FromJson <GeneratorSave>(data); ChordProgressionData chordSave = new ChordProgressionData(); /// apply the needed changes for version 1.1. was null before. if (save.mVersion == 0.0f) { save.mDistortion = new Pair_String_Float("MasterDistortion", generatorSave.mDistortion); save.mCenterFreq = new Pair_String_Float("MasterCenterFrequency", generatorSave.mCenterFreq); save.mOctaveRange = new Pair_String_Float("MasterOctaveRange", generatorSave.mOctaveRange); save.mFreqGain = new Pair_String_Float("MasterFrequencyGain", generatorSave.mFreqGain); save.mLowpassCutoffFreq = new Pair_String_Float("MasterLowpassCutoffFreq", generatorSave.mLowpassCutoffFreq); save.mLowpassResonance = new Pair_String_Float("MasterLowpassResonance", generatorSave.mLowpassResonance); save.mHighpassCutoffFreq = new Pair_String_Float("MasterHighpassCutoffFreq", generatorSave.mHighpassCutoffFreq); save.mHighpassResonance = new Pair_String_Float("MasterHighpassResonance", generatorSave.mHighpassResonance); save.mEchoDelay = new Pair_String_Float("MasterEchoDelay", generatorSave.mEchoDelay); save.mEchoDecay = new Pair_String_Float("MasterEchoDecay", generatorSave.mEchoDecay); save.mEchoDry = new Pair_String_Float("MasterEchoDry", generatorSave.mEchoDry); save.mEchoWet = new Pair_String_Float("MasterEchoWet", generatorSave.mEchoWet); save.mNumEchoChannels = new Pair_String_Float("MasterNumEchoChannels", generatorSave.mNumEchoChannels); save.mReverb = new Pair_String_Float("MasterReverb", generatorSave.mRever); save.mRoomSize = new Pair_String_Float("MasterRoomSize", generatorSave.mRoomSize); save.mReverbDecay = new Pair_String_Float("MasterReverbDecay", generatorSave.mReverbDecay); save.mGroupRate = (eGroupRate)generatorSave.mGroupRate; /// We also need to create a chord progression data object: chordSave.mExcludedProgSteps = generatorSave.mExcludedProgSteps.ToArray(); chordSave.SubdominantInfluence = generatorSave.mSubdominantInfluence; chordSave.DominantInfluence = generatorSave.mDominantInfluence; chordSave.TonicInfluence = generatorSave.mTonicInfluence; chordSave.TritoneSubInfluence = generatorSave.mTritoneSubInfluence; } return(save); }
/// <summary> /// Loads our data /// </summary> /// <param name="pathIN"></param> /// <returns></returns> public static IEnumerator LoadData(string pathIN, System.Action <MusicGeneratorData> callback) { string data = null; yield return(MusicHelpers.GetUWR("/MusicGenerator/InstrumentSaves/" + pathIN + "/generator.txt", (x) => { data = x.downloadHandler.text; })); MusicGeneratorData generatorData = JsonUtility.FromJson <MusicGeneratorData>(data); // Version check and update. if (generatorData.mVersion != MusicGenerator.Version) { ChordProgressionData chordSave = new ChordProgressionData(); string persistentDir = MusicFileConfig.GetPersistentSaveDirectory(pathIN); // apply the needed changes for version 1.1. was null before. if (generatorData.mVersion == 0.0f) { string generatorSaveData = null; yield return(MusicHelpers.GetUWR("/MusicGenerator/InstrumentSaves/" + pathIN + "/generator.txt", (x) => { generatorSaveData = x.downloadHandler.text; })); GeneratorSave generatorSave = JsonUtility.FromJson <GeneratorSave>(generatorSaveData); generatorData.mDistortion = new Pair_String_Float("MasterDistortion", generatorSave.mDistortion); generatorData.mCenterFreq = new Pair_String_Float("MasterCenterFrequency", generatorSave.mCenterFreq); generatorData.mOctaveRange = new Pair_String_Float("MasterOctaveRange", generatorSave.mOctaveRange); generatorData.mFreqGain = new Pair_String_Float("MasterFrequencyGain", generatorSave.mFreqGain); generatorData.mLowpassCutoffFreq = new Pair_String_Float("MasterLowpassCutoffFreq", generatorSave.mLowpassCutoffFreq); generatorData.mLowpassResonance = new Pair_String_Float("MasterLowpassResonance", generatorSave.mLowpassResonance); generatorData.mHighpassCutoffFreq = new Pair_String_Float("MasterHighpassCutoffFreq", generatorSave.mHighpassCutoffFreq); generatorData.mHighpassResonance = new Pair_String_Float("MasterHighpassResonance", generatorSave.mHighpassResonance); generatorData.mEchoDelay = new Pair_String_Float("MasterEchoDelay", generatorSave.mEchoDelay); generatorData.mEchoDecay = new Pair_String_Float("MasterEchoDecay", generatorSave.mEchoDecay); generatorData.mEchoDry = new Pair_String_Float("MasterEchoDry", generatorSave.mEchoDry); generatorData.mEchoWet = new Pair_String_Float("MasterEchoWet", generatorSave.mEchoWet); generatorData.mNumEchoChannels = new Pair_String_Float("MasterNumEchoChannels", generatorSave.mNumEchoChannels); generatorData.mReverb = new Pair_String_Float("MasterReverb", generatorSave.mRever); generatorData.mRoomSize = new Pair_String_Float("MasterRoomSize", generatorSave.mRoomSize); generatorData.mReverbDecay = new Pair_String_Float("MasterReverbDecay", generatorSave.mReverbDecay); generatorData.mGroupRate = (eGroupRate)generatorSave.mGroupRate; // We also need to create a chord progression data object: chordSave.mExcludedProgSteps = generatorSave.mExcludedProgSteps.ToArray(); chordSave.SubdominantInfluence = generatorSave.mSubdominantInfluence; chordSave.DominantInfluence = generatorSave.mDominantInfluence; chordSave.TonicInfluence = generatorSave.mTonicInfluence; chordSave.TritoneSubInfluence = generatorSave.mTritoneSubInfluence; } else if (generatorData.mVersion == 1.1f) { string generatorSaveData = null; yield return(MusicHelpers.GetUWR("/MusicGenerator/InstrumentSaves/" + pathIN + "/generator.txt", (x) => { generatorSaveData = x.downloadHandler.text; })); GeneratorSave generatorSave = JsonUtility.FromJson <GeneratorSave>(generatorSaveData); generatorData.mGroupOdds.Clear(); for (int i = 0; i < generatorSave.mGroupOdds.Count; i++) { generatorData.mGroupOdds.Add(generatorSave.mGroupOdds[i]); } } } callback(generatorData); yield return(null); }