/// <inheritdoc />
        public void SetParameterAutomated(int index, float value)
        {
            RaisePluginCalled("SetParameterAutomated(" + index + ", " + value + ")");

            // This chunk of code handles investigation of a preset format in order to be able to
            // reverse engineer where the different changes to the parameters are stored within the preset file.
            string name    = PluginContext.PluginCommandStub.GetParameterName(index);
            string label   = PluginContext.PluginCommandStub.GetParameterLabel(index);
            string display = PluginContext.PluginCommandStub.GetParameterDisplay(index);

            if ("".Equals(display))
            {
                display = "" + value;
            }
            Debug.WriteLine(string.Format("SetParameterAutomated. Name: {0}, Label: {1}, Value: {2}", name, label, display));

            if (DoInvestigatePluginPresetFileFormat)
            {
                // read in the preset chunk and
                // do a binary comparison between what changed before and after this method was called
                byte[] chunkData = PluginContext.PluginCommandStub.GetChunk(true);

                // if we are tracking a specific number of bytes from the chunk, store those
                if (DoTrackPluginPresetFileFormat)
                {
                    if (TrackPluginPresetFilePosition > -1 && TrackPluginPresetFileNumberOfBytes > 0)
                    {
                        var trackedChunkData = new byte[TrackPluginPresetFileNumberOfBytes];
                        Array.Copy(chunkData, TrackPluginPresetFilePosition, trackedChunkData, 0, TrackPluginPresetFileNumberOfBytes);
                        TrackPluginPresetFileBytes = trackedChunkData;
                    }
                }

                // if the chunk is not empty, try to detect what has changed
                if (chunkData != null && chunkData.Length > 0)
                {
                    int chunkLength = chunkData.Length;

                    // TODO: DELETE THIS

                    /*
                     * string wavesPluginName = WavesPreset.GetPluginName(chunkData);
                     * if (wavesPluginName != null) {
                     *      switch (wavesPluginName) {
                     *              case "SSLChannel":
                     *                      WavesSSLChannel sslChannel = new WavesSSLChannel();
                     *                      sslChannel.ReadChunkData(chunkData);
                     *                      sslChannel.Write("sslchannel-output.txt");
                     *                      break;
                     *              case "SSLComp":
                     *                      WavesSSLComp sslComp = new WavesSSLComp();
                     *                      sslComp.ReadChunkData(chunkData);
                     *                      sslComp.Write("sslcomp-output.txt");
                     *                      break;
                     *              case "PuigChild":
                     *                      break;
                     *      }
                     * }
                     */

                    // binary comparison to find out where the chunk has changed
                    if (previousChunkData != null && previousChunkData.Length > 0)
                    {
                        if (debugChunkFiles)
                        {
                            BinaryFile.ByteArrayToFile("Preset Chunk Data - previousChunkData.dat", previousChunkData);
                            BinaryFile.ByteArrayToFile("Preset Chunk Data - chunkData.dat", chunkData);
                        }

                        if (InvestigatePluginPresetFileFormatDiffType == DiffType.Binary)
                        {
                            SimpleBinaryDiff.Diff diff = SimpleBinaryDiff.GetDiff(previousChunkData, chunkData);
                            if (diff != null)
                            {
                                Debug.WriteLine(string.Format("BinDiff: {0}", diff));

                                // store each of the chunk differences in a list
                                foreach (SimpleBinaryDiff.DiffPoint point in diff.Points)
                                {
                                    this.InvestigatedPluginPresetFileFormatList.Add(
                                        new InvestigatedPluginPresetFileFormat(point.Index, point.NewValue, name, label, display));
                                }
                            }
                        }
                        else if (InvestigatePluginPresetFileFormatDiffType == DiffType.Text)
                        {
                            // assume we are dealing with text and not binary data
                            var    d       = new Differ();
                            string OldText = BinaryFile.ByteArrayToString(previousChunkData);
                            string NewText = BinaryFile.ByteArrayToString(chunkData);

                            DiffResult res = d.CreateWordDiffs(OldText, NewText, true, true, new[] { ' ', '\r', '\n' });
                            //DiffResult res = d.CreateCharacterDiffs(OldText, NewText, true, true);

                            List <UnidiffEntry> diffList = UnidiffSeqFormater.GenerateWithLineNumbers(res);
                            var queryTextDiffs           = from dl in diffList
                                                           where dl.Type == UnidiffType.Insert
                                                           select dl;

                            foreach (var e in queryTextDiffs)
                            {
                                string text = e.Text;
                                text = text.Replace("\n", "");
                                if (text != "")
                                {
                                    System.Diagnostics.Debug.WriteLine(String.Format("TextDiff: {0} {1}", e.Index, text));

                                    this.InvestigatedPluginPresetFileFormatList.Add(
                                        new InvestigatedPluginPresetFileFormat(e.Index, 0, name, label, display, text));
                                }
                            }
                        }
                    }
                    previousChunkData = chunkData;
                }
            }
        }
        private void DetectChunkChanges(byte[] previousChunkData, byte[] chunkData, string paramName, string paramLabel, string paramDisplay, string paramValue)
        {
            bool     debugChunkFiles = true;
            DiffType InvestigatePluginPresetFileFormatDiffType = DiffType.Binary;

            // do a binary comparison between what changed before and after this method was called

            // if the chunk is not empty, try to detect what has changed
            if (chunkData != null && chunkData.Length > 0)
            {
                int chunkLength = chunkData.Length;

                // binary comparison to find out where the chunk has changed
                if (previousChunkData != null && previousChunkData.Length > 0)
                {
                    if (debugChunkFiles)
                    {
                        BinaryFile.ByteArrayToFile("Preset Chunk Data - previousChunkData.dat", previousChunkData);
                        BinaryFile.ByteArrayToFile("Preset Chunk Data - chunkData.dat", chunkData);
                    }

                    if (InvestigatePluginPresetFileFormatDiffType == DiffType.Binary)
                    {
                        SimpleBinaryDiff.Diff diff = SimpleBinaryDiff.GetDiff(previousChunkData, chunkData);
                        if (diff != null)
                        {
                            Debug.WriteLine(string.Format("BinDiff: {0}", diff));

                            // store each of the chunk differences in a list
                            foreach (SimpleBinaryDiff.DiffPoint point in diff.Points)
                            {
                                this.InvestigatedPluginPresetFileFormatList.Add(
                                    new InvestigatedPluginPresetFileFormat(point.Index, point.NewValue, paramName, paramLabel, paramDisplay, null, paramValue));
                            }
                        }
                    }
                    else if (InvestigatePluginPresetFileFormatDiffType == DiffType.Text)
                    {
                        // assume we are dealing with text and not binary data
                        var    d       = new Differ();
                        string OldText = BinaryFile.ByteArrayToString(previousChunkData);
                        string NewText = BinaryFile.ByteArrayToString(chunkData);

                        DiffResult res = d.CreateWordDiffs(OldText, NewText, true, true, new[] { ' ', '\r', '\n' });
                        //DiffResult res = d.CreateCharacterDiffs(OldText, NewText, true, true);

                        List <UnidiffEntry> diffList = UnidiffSeqFormater.GenerateWithLineNumbers(res);
                        var queryTextDiffs           = from dl in diffList
                                                       where dl.Type == UnidiffType.Insert
                                                       select dl;

                        foreach (var e in queryTextDiffs)
                        {
                            string text = e.Text;
                            text = text.Replace("\n", "");
                            if (text != "")
                            {
                                System.Diagnostics.Debug.WriteLine(String.Format("TextDiff: {0} {1}", e.Index, text));

                                this.InvestigatedPluginPresetFileFormatList.Add(
                                    new InvestigatedPluginPresetFileFormat(e.Index, 0, paramName, paramLabel, paramDisplay, text, paramValue));
                            }
                        }
                    }
                }
            }
        }