Esempio n. 1
0
        /// <summary>
        /// Load one file into a specific cell
        /// </summary>
        /// <param name="file">file info</param>
        /// <param name="selectedCell">selectedCell cell</param>
        void LoadFileIntoCell(FileInfo file, int selectedCell)
        {
            if (file.Extension.Equals(".h2p"))
            {
                var wavetable = Zebra2OSCPreset.Read(file.FullName);
                if (wavetable != null)
                {
                    // clear first
                    ClearAllCells();

                    // set the data
                    for (int i = 0; i < wavetable.Length; i++)
                    {
                        Array.Copy(wavetable[i], 0, this.soundData[i], 0, 128);

                        // store the raw waves into the morphed data as this is used to morph between
                        this.morphedData[i] = this.soundData[i];

                        // update the wave displays as well
                        this.waveDisplays[i].WaveData    = this.soundData[i];
                        this.waveDisplays[i].MorphedData = this.morphedData[i];

                        // TODO: use loaded instead of filename to determine that these are also loaded
                        this.waveDisplays[i].FileName = file.FullName;
                        this.waveDisplays[i].Loaded   = true;
                        this.waveDisplays[i].Refresh();
                    }
                }
                else
                {
                    throw new FileLoadException("Could not read the u-he Zebra 2 Oscillator preset file.", file.FullName);
                }
            }
            else
            {
                float[] tempAudioBuffer  = BassProxy.ReadMonoFromFile(file.FullName);
                float[] tempAudioBuffer2 = MathUtils.Resample(tempAudioBuffer, 128);

                Array.Copy(tempAudioBuffer2, 0, this.soundData[selectedCell], 0, 128);

                // store the raw waves into the morphed data as this is used to morph between
                this.morphedData[selectedCell] = this.soundData[selectedCell];

                // update the wave displays as well
                this.waveDisplays[selectedCell].WaveData    = this.soundData[selectedCell];
                this.waveDisplays[selectedCell].MorphedData = this.morphedData[selectedCell];

                this.waveDisplays[selectedCell].FileName = file.FullName;
                this.waveDisplays[selectedCell].Loaded   = true;
                this.waveDisplays[selectedCell].Refresh();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Find all the segments and morph between them.
        /// E.g. if cell 0, 7 and 15 are loaded, this will mean two morphs:
        /// first between cell 0 and 7 and the second between cell 7 and 15
        /// </summary>
        void CalculateGhosts()
        {
            // get loaded slots to include in the morph
            var enabledSlots = new bool[16];

            for (int i = 0; i < 16; i++)
            {
                enabledSlots[i] = this.waveDisplays[i].Loaded;
            }

            // and morph between all the segments
            Zebra2OSCPreset.MorphAllSegments(enabledSlots, ref morphedData);

            // Set the morphed data
            for (int j = 0; j < 16; j++)
            {
                this.waveDisplays[j].MorphedData = this.morphedData[j];
                this.waveDisplays[j].Refresh();
            }
        }
Esempio n. 3
0
        void ExportToZebra2(bool doExportMorphed, bool doExportRaw)
        {
            // keep on asking for file path until it is succesfully stored
            // in the ini file
            while (!File.Exists(iniFileName))
            {
                this.OutputText = "Export path is not set";
                MakeUserSetExportPath();
                this.OutputText = "";
            }

            string pathName = ReadExportPathName();

            if (!HasRawExportName)
            {
                this.OutputText = "There's nothing to export.";
            }
            else
            {
                string filePath = "";

                #region Morphed
                if (doExportMorphed)
                {
                    filePath = pathName + Path.DirectorySeparatorChar + this.exportFileName.Text;
                    filePath = FixExportNames(filePath, true);
                    filePath = IOUtils.NextAvailableFilename(filePath);

                    // always include all slots when morphing
                    var enabledSlots = new bool[16];
                    for (int j = 0; j < 16; j++)
                    {
                        enabledSlots[j] = true;
                    }
                    Zebra2OSCPreset.Write(this.morphedData, enabledSlots, filePath);
                }
                #endregion

                #region RAW
                if (doExportRaw)
                {
                    filePath = pathName + Path.DirectorySeparatorChar + this.exportFileName.Text;
                    filePath = FixExportNames(filePath, false);
                    filePath = IOUtils.NextAvailableFilename(filePath);

                    // set wav enabled slots
                    // TODO: use loaded instead of filename to determine that these are also loaded
                    var enabledSlots = new bool[16];
                    for (int j = 0; j < 16; j++)
                    {
                        if (!string.IsNullOrEmpty(this.waveDisplays[j].FileName))
                        {
                            enabledSlots[j] = true;
                        }
                    }
                    Zebra2OSCPreset.Write(this.soundData, enabledSlots, filePath);
                }
                #endregion

                this.outputField.Text = "File exported as: " + Path.GetFileName(filePath);
            }
        }