private void GetMeasuresAndCalculatedColumnsCommandExecute(object sender, EventArgs e)
        {
            try
            {
                var    bismInfoProvider = GetBismInfoProvider();
                string measuresText     = bismInfoProvider.GetMeasuresText();
                var    activeTextView   = GetActiveTextView();

                EditArray editArray = new EditArray(GetSource(), activeTextView, false, "Load measures and calculated columns");
                if (editArray != null)
                {
                    TextSpan span = new TextSpan();
                    span.iStartLine  = 0;
                    span.iStartIndex = 0;
                    span.iEndLine    = 9999;
                    span.iEndIndex   = 0;

                    editArray.Add(new EditSpan(span, measuresText));
                    editArray.ApplyEdits();
                }
            }
            catch (Exception exc)
            {
                DisplayExceptionWindow(exc);
            }
        }
Beispiel #2
0
        /// <summary>
        /// This method formats the given span using the given EditArray.
        /// An empty input span means reformat the entire document.
        /// </summary>
        public override void ReformatSpan(EditArray mgr, TextSpan span)
        {
            Babel.LanguageService langService = this.LanguageService as Babel.LanguageService;
            DaxFormatter          formatter   = new DaxFormatter(this, mgr, span, Environment.NewLine, this.LanguageService.Preferences, langService.FormattingPage.IndentDepthInFunctions, langService.FormattingPage.FormatterType);

            formatter.Format();
        }
Beispiel #3
0
        public override TextSpan UncommentLines(TextSpan span, string lineComment)
        {
            // Remove line comments
            int clen    = lineComment.Length;
            var editMgr = new EditArray(this, null, true, "UncommentLines");

            for (int line = span.iStartLine; line <= span.iEndLine; line++)
            {
                int    i    = this.ScanToNonWhitespaceChar(line);
                string text = base.GetLine(line);

                if ((i + clen) <= text.Length && text.Substring(i, clen) == lineComment)
                {
                    var es = new EditSpan(new TextSpan()
                    {
                        iEndLine    = line,
                        iStartLine  = line,
                        iStartIndex = i,
                        iEndIndex   = i + clen
                    }, "");
                    editMgr.Add(es); // remove line comment.

                    if (line == span.iStartLine && span.iStartIndex != 0)
                    {
                        span.iStartIndex = i;
                    }
                }
            }

            editMgr.ApplyEdits();

            span.iStartIndex = 0;
            return(span);
        }
Beispiel #4
0
    public static void conv(string tspFilePath, string soundFilePath, string outFilePath)
    {
        double[] tspSignal, soundSignal, impulseSignal;
        short[]  shortSignal;

        //TSP読込
        WavRead.ReadWave(tspFilePath);
        tspSignal = EditArray.int2double(WavRead.valuesR);
        Array.Reverse(tspSignal);

        //音源読込
        WavRead.ReadWave(soundFilePath);
        soundSignal = EditArray.int2double(WavRead.valuesR);

        //畳込
        double length_bit_do = Math.Log(WavRead.valuesR.Length, 2);
        int    length_bit    = (int)length_bit_do;

        impulseSignal = new double[WavRead.valuesR.Length];
        impulseSignal = AcousticMath.Convolution(soundSignal, tspSignal, length_bit);

        //short変換
        shortSignal = EditArray.double2short(impulseSignal);

        //インパルス応答書出
        WavWrite.createWave(shortSignal, outFilePath, channel, sampleRate, bitPerSample);
    }
Beispiel #5
0
        private void DoFormatting(EditArray mgr, TextSpan span)
        {
            // Make sure there is one space after every comma unless followed
            // by a tab or comma is at end of line.
            IVsTextLines pBuffer = this.GetTextLines();

            if (pBuffer != null)
            {
                int numlines;
                int endCol;
                pBuffer.GetLineCount(out numlines);
                settings_pkg.set_reformat_types(false);
                pBuffer.GetLengthOfLine(span.iEndLine, out endCol);
                string s = this.GetText(span.iStartLine, 0, span.iEndLine, endCol);
                string t = reformat_pkg_pkg.reformat__2(s, span.iStartLine, span.iEndLine);

                TextSpan editTextSpan = new TextSpan();

                editTextSpan.iStartLine  = span.iStartLine;
                editTextSpan.iEndLine    = span.iEndLine;
                editTextSpan.iStartIndex = 0;
                editTextSpan.iEndIndex   = endCol;

                // Add edit operation
                mgr.Add(new EditSpan(editTextSpan, t));
                // Apply all edits
                mgr.ApplyEdits();
            }
        }
Beispiel #6
0
    public void StartFFT()
    {
        //wav読込
        string waveFilePath1 = Application.dataPath + wav_name;

        Debug.Log(waveFilePath1);
        if (!File.Exists(waveFilePath1))
        {
            Debug.Log("ファイルどこじゃ?");
        }
        WavRead.ReadWave(waveFilePath1);

        //double変換、二次元配列化
        //width長のがlength-width個
        //重くなるからとりまwidth長がshiftずらし
        fftSignal = new double[WavRead.valuesR.Length / shift][];
        Parallel.For(0, fftSignal.Length, i =>
        {
            fftSignal[i] = new double[width];
            for (int j = 0; j < fftSignal[i].Length; j++)
            {
                fftSignal[i][j] = (double)WavRead.valuesR[i + j * shift];
            }
        });

        //窓
        Parallel.For(0, fftSignal.Length, i =>
        {
            fftSignal[i] = AcousticMath.Windowing(fftSignal[i], "Hamming");
        });

        //fft
        double length_bit_do = Math.Log(width, 2);
        int    length_bit    = (int)length_bit_do;

        double[][] fftRe    = new double[fftSignal.Length][];
        double[][] fftIm    = new double[fftSignal.Length][];
        double[][] outfftIm = new double[fftSignal.Length][];
        double[][] outfft   = new double[fftSignal.Length][];
        Parallel.For(0, fftSignal.Length, i =>
        {
            fftRe[i]    = new double[width];
            fftIm[i]    = new double[width];
            outfftIm[i] = new double[width];
            outfft[i]   = new double[width / 2];
            AcousticMath.FFT(length_bit, fftSignal[i], fftIm[i], out fftRe[i], out outfftIm[i]);

            for (int j = 0; j < fftSignal[i].Length / 2; j++)
            {
                outfft[i][j] = Math.Sqrt(fftRe[i][j] * fftRe[i][j] + outfftIm[i][j] * outfftIm[i][j]);
            }
        });

        //float変換
        soundSignal = EditArray.double2float(outfft);

        //画面に収まるよに正規化
        EditArray.normalize(soundSignal, 50);
    }
 /// <summary>
 /// Reformat the text buffer
 /// </summary>
 void FormatBuffer(Source src)
 {
     using (EditArray edits = new EditArray(src, null, false, Resources.ReformatBuffer))
     {
         TextSpan span = src.GetDocumentSpan();
         src.ReformatSpan(edits, span);
     }
 }
Beispiel #8
0
 /// <summary>
 /// Reformat the text buffer
 /// </summary>
 private void FormatBuffer(Microsoft.VisualStudio.Package.Source src)
 {
     using (var edits = new EditArray(src, null, false, "Reformat"))
     {
         var span = src.GetDocumentSpan();
         src.ReformatSpan(edits, span);
     }
 }
 public DaxFormatter(Babel.Source source, EditArray mgr, TextSpan formattingSpan, string eolText, LanguagePreferences languagePreferences, int indentDepth, string formatterType)
 {
     _source              = source;
     _editManager         = mgr;
     _formattingSpan      = formattingSpan;
     _eolText             = eolText;
     _languagePreferences = languagePreferences;
     _indentDepth         = indentDepth;
     _formatterType       = formatterType;
 }
Beispiel #10
0
 public override void ReformatSpan(EditArray mgr, TextSpan span)
 {
     string description = "Reformat code";
     CompoundAction ca = new CompoundAction(this, description);
     using (ca)
     {
         ca.FlushEditActions();      // Flush any pending edits
         DoFormatting(mgr, span);    // Format the span
     }
 }
Beispiel #11
0
    public void playWav()
    {
        string outFilePath = Application.dataPath + inputField.text;

        WavRead.ReadWave(outFilePath);
        float[] newWavClip = EditArray.int2float(WavRead.valuesR);

        audioSource      = gameObject.GetComponent <AudioSource>();
        audioSource.clip = AudioClip.Create("newwav", newWavClip.Length, 1, 48000, false);
        audioSource.clip.SetData(newWavClip, 0);
        audioSource.volume = 0.001f;
        audioSource.Play();
    }
Beispiel #12
0
        private void DoFormatting(EditArray mgr, TextSpan span)
        {
            IndentInitialize();
            IVsTextLines pBuffer = GetTextLines();

            if (pBuffer != null)
            {
                List <EditSpan> changeList = NPLFormatHelper.ReformatCode(pBuffer, indents, comments, unFormat, span);
                if (changeList != null)
                {
                    foreach (EditSpan editSpan in changeList)
                    {
                        // Add edit operation
                        mgr.Add(editSpan);
                    }
                    mgr.ApplyEdits();
                }
            }
        }
Beispiel #13
0
        private void DoFormatting(EditArray mgr, TextSpan span)
        {
            // Make sure there is one space after every comma unless followed
            // by a tab or comma is at end of line.
            IVsTextLines pBuffer = GetTextLines();

            if (pBuffer != null)
            {
                List <EditSpan> changeList = AsmHighlighterFormatHelper.ReformatCode(pBuffer, span, LanguageService.GetLanguagePreferences().TabSize);
                if (changeList != null)
                {
                    foreach (EditSpan editSpan in changeList)
                    {
                        // Add edit operation
                        mgr.Add(editSpan);
                    }
                }
            }
        }
    /// <summary>
    /// スペクトル表示
    /// </summary>
    public void startFFTVisual()
    {
        //wav読込
        string waveFilePath1 = Application.dataPath + inputField[0].text;

        Debug.Log(waveFilePath1);
        if (!File.Exists(waveFilePath1))
        {
            Debug.Log("ファイルどこじゃ?");
        }
        WavRead.ReadWave(waveFilePath1);

        //double変換
        signals.fftSignal = EditArray.int2double(WavRead.valuesR);

        //窓
        signals.fftSignal = AcousticMath.Windowing(signals.fftSignal, "Hamming");

        //fft
        double length_bit_do = Math.Log(signals.fftSignal.Length, 2);
        int    length_bit    = (int)length_bit_do;

        double[] fftRe    = new double[signals.fftSignal.Length];
        double[] fftIm    = new double[signals.fftSignal.Length];
        double[] outfftIm = new double[signals.fftSignal.Length];

        AcousticMath.FFT(length_bit, signals.fftSignal, fftIm, out fftRe, out outfftIm);

        double[] outfft = new double[signals.fftSignal.Length / 2];
        for (int i = 0; i < signals.fftSignal.Length / 2; i++)
        {
            outfft[i] = Math.Sqrt(fftRe[i] * fftRe[i] + outfftIm[i] * outfftIm[i]);
        }

        //float変換
        signals.soundSignal = EditArray.double2float(outfft);

        //画面に収まるよに正規化
        EditArray.normalize(signals.soundSignal, 1);

        Display();
    }
Beispiel #15
0
        private void DoFormatting(EditArray mgr, TextSpan span)
        {
            // Make sure there is one space after every comma unless followed
            // by a tab or comma is at end of line.
            IVsTextLines pBuffer = GetTextLines();
            if (pBuffer != null)
            {
//                List<EditSpan> changeList = new List<EditSpan>();

                // BETA DISABLED
                List<EditSpan> changeList = NShaderFormatHelper.ReformatCode(pBuffer, span, LanguageService.GetLanguagePreferences().TabSize);
                foreach (EditSpan editSpan in changeList)
                {
                    // Add edit operation
                    mgr.Add(editSpan);
                }
                // Apply all edits
                mgr.ApplyEdits();
            }
        }
    /// <summary>
    /// 波形表示
    /// </summary>
    public void startVisual()
    {
        //wav読込
        string waveFilePath1 = Application.dataPath + inputField[0].text;

        Debug.Log(waveFilePath1);
        if (!File.Exists(waveFilePath1))
        {
            Debug.Log("ファイルどこじゃ?");
        }
        WavRead.ReadWave(waveFilePath1);

        //float変換
        signals.soundSignal = new float[WavRead.valuesR.Length];
        signals.soundSignal = EditArray.int2float(WavRead.valuesR);

        //画面に収まるよに正規化
        EditArray.normalize(signals.soundSignal, 1);

        Display();
    }
        private void InsertStabsIntoSource()
        {
            var methodStubInfos = ReadMethodStubInfosFromDataGrideView().ToArray();
            var laggSrv         = _source.LanguageService;
            var pref            = laggSrv.Preferences;
            var sufix           = methodStubInfos.Length > 1 ? "s" : "";
            var editArray       = new EditArray(_source, null, true, "implement interface" + sufix + " stub" + sufix);

            _source.LockWrite();
            try
            {
                MakeChanges(methodStubInfos, pref, editArray);
                editArray.ApplyEdits();
                Close();
            }
            catch (Exception ex) { _source.ProjectInfo.ShowMessage("Error: " + ex.Message, MessageType.Error); }
            finally
            {
                editArray.Dispose();
                _source.UnlockWrite();
            }
        }
    public void startVisual()
    {
        //wav読込
        string waveFilePath1 = Application.dataPath + inputField[0].text;

        Debug.Log(waveFilePath1);
        if (!File.Exists(waveFilePath1))
        {
            Debug.Log("ファイルどこじゃ?");
        }
        WavRead.ReadWave(waveFilePath1);

        //double変換、二次元配列化
        //重くなるからとりまwidth長shiftずらしが何個?
        signals.fftSignal = new double[WavRead.valuesR.Length / shift][];
        Parallel.For(0, signals.fftSignal.Length, i =>
        {
            signals.fftSignal[i] = new double[width];
            for (int j = 0; j < signals.fftSignal[i].Length; j++)
            {
                signals.fftSignal[i][j] = (double)WavRead.valuesR[i + j * shift];
            }
        });

        //窓
        Parallel.For(0, signals.fftSignal.Length, i =>
        {
            signals.fftSignal[i] = AcousticMath.Windowing(signals.fftSignal[i], "Hamming");
        });

        //fft
        double length_bit_do = Math.Log(width, 2);
        int    length_bit    = (int)length_bit_do;

        double[][] fftRe    = new double[signals.fftSignal.Length][];
        double[][] fftIm    = new double[signals.fftSignal.Length][];
        double[][] outfftIm = new double[signals.fftSignal.Length][];
        double[][] outfft   = new double[signals.fftSignal.Length][];
        Parallel.For(0, signals.fftSignal.Length, i =>
        {
            fftRe[i]    = new double[width];
            fftIm[i]    = new double[width];
            outfftIm[i] = new double[width];
            outfft[i]   = new double[width / 2];
            AcousticMath.FFT(length_bit, signals.fftSignal[i], fftIm[i], out fftRe[i], out outfftIm[i]);

            for (int j = 0; j < signals.fftSignal[i].Length / 2; j++)
            {
                outfft[i][j] = Math.Sqrt(fftRe[i][j] * fftRe[i][j] + outfftIm[i][j] * outfftIm[i][j]);
            }
        });

        //float変換
        signals.soundSignal = EditArray.double2float(outfft);
        Debug.Log("signals.soundSignal.Length:" + signals.soundSignal.Length);
        Debug.Log("signals.soundSignal[0].Length:" + signals.soundSignal[0].Length);

        //画面に収まるよに正規化
        EditArray.normalize(signals.soundSignal, 1);

        Display();
    }
// ReSharper disable ParameterTypeCanBeEnumerable.Local
        private void MakeChanges(IGrouping <FixedType.Class, MemberImplInfo>[] stubs, LanguagePreferences pref, EditArray editArray)
// ReSharper restore ParameterTypeCanBeEnumerable.Local
        {
            var newLine = Environment.NewLine;

            foreach (var stub in stubs)
            {
                var sb = MakeStubsForTypeMembers(stub);

                // На данном этапе в "sb" находится текст заглушек для членов тела которых отбиты одной табуляцией на отступ.
                // Заменяем этот табы на отступ указанный в настройках студии для Nemerle.
                // TODO: Надо сразу генерировать правлиьные отступы, а не пользоваться табами, так как отступы
                // могут быть не кратными размеру табуляции. При этом отступы должны дополняться пробелами.
                // подроности смотри в MakeIndentString().

                if (!pref.InsertTabs && pref.IndentSize == 1)
                {
                    sb.Replace("\t", pref.MakeIndentString());
                }

                // Кроме того члены не имеют отсупа от левого края. Отступ должен совпадать с отступом
                // типа в который помещаются плюс один отступ.
                // Кроме того пользователю будет удобно если добавляемые члены будут добавлены после
                // последнего члена того же (т.е. типа чьи члены реализуются) типа уже имеющегося в данном типе.
                // Таким образом мы должны попытаться найти уже реализованные типы. В них найти самый послединй,
                // и вставить новые члены после него. Если в текущем типе (_ty) еще не было реализовано членов
                // подтипа (например, интерфейса) к которому относятся добавляемые члены, то производим вставку
                // в конец текущего типа.

                TextPoint pt;
                string    indent;

                var lastImplementedMembers = NUtils.GetLastImplementedMembersOfInterface(_ty, stub.Key);

                #region Calc indent and insertion point

                if (lastImplementedMembers.IsSome)
                {
                    // Используем meber.Value для получения места вставки
                    var endLine = lastImplementedMembers.Value.Location.EndLine;
                    var text    = _source.GetLine(endLine);
                    indent = text.GetLiadingSpaces();
                    pt     = new TextPoint(endLine + 1, 1);
                    //TODO: Этот код рассчитывает на то, что за членом не идет многострочного коментария
                    // или другого члена. Надо бы сделать реализацию не закладывающуюся на это.
                }
                else                 // Ни одного члена этого интерфейса не реализовано в классе...
                {
                    // Оборачиваем реализуемые методы в #region
                    if (_cbGenerateRegion.Checked)
                    {
                        sb.Insert(0, "#region " + stub.Key + "  Members" + newLine + newLine);
                        sb.AppendLine("#endregion" + newLine);
                    }
                    // Вставляем описание интерфейса в конец класса
                    var endLine = _ty.Location.EndLine;
                    var text    = _source.GetLine(endLine);
                    indent  = text.GetLiadingSpaces();
                    pt      = new TextPoint(endLine, 1);
                    indent += pref.MakeIndentString();
                    //TODO: Этот код рассчитывает на то, что конец типа распологается на отдельной строке.
                    // Надо бы сделать реализацию не закладывающуюся на это.
                }

                #endregion

                sb.Insert(0, indent);
                sb.Replace("\n", "\n" + indent);
                TrimEnd(sb);

                var inertLoc = new Location(_source.FileIndex, pt, pt);
                editArray.Add(new EditSpan(inertLoc.ToTextSpan(), sb.ToString()));
            }
        }
Beispiel #20
0
 public override void ReformatSpan(EditArray mgr, TextSpan span)
 {
     base.ReformatSpan(mgr, span);
 }