// pass window parameter to render in sceneviews that are not the active view. public static void Window(GUIContent title, WindowFunction sceneViewFunc, int order, Object target, WindowDisplayOption option, EditorWindow window = null) { if (Event.current.type != EventType.Layout) { return; } foreach (var overlayWindow in s_Windows) { if (option == WindowDisplayOption.OneWindowPerTarget && overlayWindow.target == target && target != null) { return; } if (option == WindowDisplayOption.OneWindowPerTitle && (overlayWindow.title == title || overlayWindow.title.text == title.text)) { return; } } var newWindow = new OverlayWindow(title, sceneViewFunc, order, target, option) { secondaryOrder = s_Windows.Count, canCollapse = false }; s_Windows.Add(newWindow); }
public static void BlockIfConfigured(WindowFunction function, int windowId) { if (Settings.BlacklistedIMGUIPlugins.Count == 0) { return; } var method = function.Method; if (!HandledMethods.Contains(method)) { HandledMethods.Add(method); try { if (IsBlackslisted(method)) { XuaLogger.AutoTranslator.Info("Attempting to hook " + method.DeclaringType.FullName.ToString() + "." + method.Name + " to disable translation in window."); IMGUIWindow_Function_Hook.Register(method); HookingHelper.PatchType(typeof(IMGUIWindow_Function_Hook), Settings.ForceMonoModHooks); IMGUIWindow_Function_Hook.Clean(); } } catch (Exception e) { XuaLogger.AutoTranslator.Error(e, "An error occurred while attempting to hook " + method.DeclaringType.FullName.ToString() + " to disable translation in window."); } } }
// pass window parameter to render in sceneviews that are not the active view. public static void Window(GUIContent title, WindowFunction sceneViewFunc, int order, Object target, WindowDisplayOption option, EditorWindow window = null) { if (Event.current.type != EventType.Layout) { return; } foreach (OverlayWindow overlayWindow in m_Windows) { if (option == WindowDisplayOption.OneWindowPerTarget && overlayWindow.m_Target == target && target != null) { return; } if (option == WindowDisplayOption.OneWindowPerTitle && (overlayWindow.m_Title == title || overlayWindow.m_Title.text == title.text)) { return; } } OverlayWindow newWindow = new OverlayWindow(); newWindow.m_Title = title; newWindow.m_SceneViewFunc = sceneViewFunc; newWindow.m_PrimaryOrder = order; newWindow.m_SecondaryOrder = m_Windows.Count; // just use a value that is unique across overlays newWindow.m_Target = target; newWindow.m_EditorWindow = window; m_Windows.Add(newWindow); }
protected Processor() { waveFile = null; hammingWindow = null; enegryArray = null; endPointList = new List <double>(); }
/// <summary> /// 生成メソッド /// </summary> /// <param name="wavedata">波形データ</param> /// <param name="size">サンプルした波形のサイズ</param> /// <param name="func">窓関数の種類</param> /// <returns>初期化生成したMySpectrumClassクラスのアドレス</returns> public static MyFFTDataFunction Load(double[] wavedata, int size, WindowFunction func) { MyFFTDataFunction msc = new MyFFTDataFunction(); //生成 msc.Initialize(wavedata, size, func); return(msc); }
public LpcFeaturesExtractor(float sampleRate, int poles) : base(sampleRate) { this.poles = poles; windowFunction = new HammingWindowFunction(windowSize); lpc = new LinearPredictiveCoding(windowSize, poles); }
public override async Task OnActivateAsync() { streamProvider = GetStreamProvider("SMSProvider"); jobManager = GrainFactory.GetGrain <IJobManagerGrain>(0, "JobManager"); var window = await jobManager.GetWindow(this.GetPrimaryKey()); window_length = window.Item1; window_slide = window.Item2; func = new WindowFunction(window_length, window_slide); // ask the JobManager which streams it should subscribe var subscribe = await jobManager.GetSubscribe(this.GetPrimaryKey()); foreach (var streamID in subscribe) { var stream = streamProvider.GetStream <MyType>(streamID, null); // To resume stream in case of stream deactivation var subscriptionHandles = await stream.GetAllSubscriptionHandles(); if (subscriptionHandles.Count > 0) { foreach (var subscriptionHandle in subscriptionHandles) { await subscriptionHandle.ResumeAsync(Process); } } // explicitly subscribe to a stream await stream.SubscribeAsync(Process); } }
static void Prefix(int id, WindowFunction func, GUIContent title) { IMGUIBlocker.BlockIfConfigured(func, id); IMGUIPluginTranslationHooks.HookIfConfigured(func); AutoTranslationPlugin.Current.Hook_TextChanged(title, false); }
/// <summary> /// 線形位相バンドパスフィルタの係数を計算する。 /// 右側半分のみを計算。 /// </summary> /// <param name="type">フィルタタイプ</param> /// <param name="n">タップ数=2n+1</param> /// <param name="w">遮断周波数(BPF の場合は遮断帯域幅、HPF の場合は π-遮断周波数)</param> /// <param name="w0">(BPF のみ) 中心周波数</param> /// <param name="window">窓関数</param> /// <returns>係数の右側半分を計算したもの</returns> public static void CalcLinearBPFCoefficient(FirFilterType type, double[] coef, double w, double w0, WindowFunction window) { int n = coef.Length; double sum; sum = coef[0] = window(0) * w; for(int i=1; i<n; ++i) { double tmp = window(i) * Math.Sin(w * i) / i; sum += tmp * 2; if(type == FirFilterType.LPF) { coef[i] = tmp; } else if(type == FirFilterType.HPF) { if(i%2 != 0) coef[i] = -tmp; else coef[i] = tmp; } else { coef[i] = 2 * Math.Cos(w0 * i) * tmp; } } for(int i=0; i<n; ++i) { coef[i] /= sum; } }//GetLinearBPFCoefficient
/// <summary> /// Apply a custom window function on part of a signal. /// </summary> /// <param name="samples">Signal to window</param> /// <param name="left">Window function left from the marker</param> /// <param name="right">Window function right from the marker</param> /// <param name="start">Beginning of the window in samples</param> /// <param name="splitter">The point where the two window functions change</param> /// <param name="end">End of the window in samples</param> public static void ApplyWindow(float[] samples, Window left, Window right, int start, int splitter, int end) { int leftSpan = splitter - start, rightSpan = end - splitter, endMirror = splitter - (end - splitter), posSplitter = Math.Max(splitter, 0); float leftSpanDiv = 2 * (float)Math.PI / (leftSpan * 2), rightSpanDiv = 2 * (float)Math.PI / (rightSpan * 2); if (left != Window.Disabled) { WindowFunction leftFunc = GetWindowFunction(left); Array.Clear(samples, 0, start); for (int sample = Math.Max(start, 0), actEnd = Math.Min(posSplitter, samples.Length); sample < actEnd; ++sample) { samples[sample] *= leftFunc((sample - start) * leftSpanDiv); } } if (right != Window.Disabled) { if (end < 0) { end = 0; } WindowFunction rightFunc = GetWindowFunction(right); for (int sample = posSplitter, actEnd = Math.Min(end, samples.Length); sample < actEnd; ++sample) { samples[sample] *= rightFunc((sample - endMirror) * rightSpanDiv); } Array.Clear(samples, end, samples.Length - end); } }
public static void Window(GUIContent title, WindowFunction sceneViewFunc, int order) { var windowFunctionDelegate = Delegate.CreateDelegate(m_WindowFunctionDelegateType, null, sceneViewFunc.Method); if (m_WindowFunc != null) { m_WindowFunc.Invoke(null, BindingFlags.InvokeMethod, null, new System.Object[] { title, windowFunctionDelegate, order, Enum.ToObject(m_WindowDisplayOptionType, 2) }, null); } }
/// <summary> /// Construct a FourierTransform that will analyze sample buffers that are /// <code>ts</code> samples long and contain samples with a <code>sr</code> /// sample rate. /// </summary> /// <param name="ts">the length of the buffers that will be analyzed</param> /// <param name="sr">the sample rate of the samples that will be analyzed</param> public FourierTransform(int ts, float sr) { timeSize = ts; sampleRate = (int)sr; bandWidth = (2.0f / timeSize) * ((float)sampleRate / 2.0f); NoAverages(); AllocateArrays(); currentWindow = new RectangularWindow(); // a Rectangular window is analogous to using no window. }
// pass window parameter to render in sceneviews that are not the active view. public static void Window(GUIContent title, WindowFunction sceneViewFunc, int order, Object target, WindowDisplayOption option, EditorWindow window = null) { if (Event.current.type != EventType.Layout) { return; } ShowWindow(new OverlayWindow(title, sceneViewFunc, order, target, option)); }
/// <summary> /// Initializes a new windower for the specified stream with the specified window and hop size. /// </summary> /// <param name="stream">the stream to read the audio data to process from</param> /// <param name="windowSize">the window size in the dimension of samples</param> /// <param name="hopSize">the hop size in the dimension of samples</param> /// <param name="windowType">the type of the window function to apply</param> public StreamWindower(IAudioStream stream, int windowSize, int hopSize, WindowType windowType) { this.stream = stream; this.windowSize = windowSize; this.hopSize = hopSize; this.windowFunction = WindowUtil.GetFunction(windowType, WindowSize); Initialize(); }
protected void DrawEngeryGraph() { WindowFunction hammingWindow = Utility.CreateWindow(); Processor processor = new Processor(waveFile, hammingWindow); processor.Process(); processor.EndPointDetect(); GraphPane graphPane = zedGraphControl.GraphPane; graphPane.Clone(); graphPane.Title.Text = Parameters.WINDOW_TYPE.ToString(); graphPane.XAxis.Title.Text = "Time"; graphPane.YAxis.Title.Text = "Amplitude"; PointPairList list = Utility.ConvertEnegryToPointPairList(processor.enegryArray.ToArray()); if (list == null) { return; } LineItem curve = graphPane.AddCurve("Enegry", list, Color.Red, SymbolType.None); if (processor.endPointList != null) { foreach (int end in processor.endPointList) { double x = Parameters.HAMMING_WINDOW_WIDE / 2 + end * (Parameters.HAMMING_WINDOW_WIDE - Parameters.COVERED_WIDE); PointPairList endList = new PointPairList(); endList.Add(x, 0); endList.Add(x, 500000000); LineItem line = graphPane.AddCurve("Endpoint", endList, Color.Blue, SymbolType.None); line.Line.Width = 1F; } } int activity = processor.ActivityDetect(); if (activity != -1) { PointPairList endList = new PointPairList(); double x = Parameters.HAMMING_WINDOW_WIDE / 2 + activity * (Parameters.HAMMING_WINDOW_WIDE - Parameters.COVERED_WIDE); endList.Add(x, 0); endList.Add(x, 500000000); LineItem line = graphPane.AddCurve("Activity", endList, Color.GreenYellow, SymbolType.None); line.Line.Width = 1F; } curve.Line.Width = 1F; //curve.Line.Fill = new Fill(Color.White, Color.Red, 45F); zedGraphControl.AxisChange(); }
public static void HookIfConfigured(WindowFunction function) { if (AutoTranslationPlugin.Current.PluginTextCaches.Count == 0) { return; } HookIfConfigured(function.Method); }
/// <summary> /// Initializes a new windower for the specified stream with the specified window and hop size. /// </summary> /// <param name="stream">the stream to read the audio data to process from</param> /// <param name="windowSize">the window size in the dimension of samples</param> /// <param name="hopSize">the hop size in the dimension of samples</param> /// <param name="windowType">the type of the window function to apply</param> public StreamWindower(IAudioStream stream, int windowSize, int hopSize, WindowType windowType, int bufferSize = DEFAULT_STREAM_INPUT_BUFFER_SIZE) { this.stream = stream; this.windowSize = windowSize; this.hopSize = hopSize; this.windowFunction = WindowUtil.GetFunction(windowType, WindowSize); this.bufferSize = bufferSize; Initialize(); }
public IFFTPullBuffer(SigParam <double[]> fftDataReal, SigParam <double[]> fftDataImag, int size, WindowFunction window) : base(size) { FFFTDataReal = fftDataReal; FFFTDataImag = fftDataImag; RealImagData = new double[size]; TimeDomain = new float[size]; Window = AudioUtils.CreateWindowDouble(size, window); WindowFunc = window; PullCount = size; }
/// <summary> /// Initializes a new instance of the <see cref="Processor"/> class. /// </summary> /// <param name="waveFile">The wave file.</param> /// <param name="hammingWindow">The hamming window.</param> public Processor(AudioUtils.WaveFile waveFile, WindowFunction hammingWindow) : this() { this.waveFile = waveFile; this.hammingWindow = hammingWindow; if (hammingWindow == null) { hammingWindow = Utility.CreateWindow(); } }
public InverseSTFT(IAudioWriterStream stream, int windowSize, int hopSize, int fftSize, WindowType windowType, float windowNormalizationFactor) : base(stream, windowSize, hopSize) { if (fftSize < windowSize) { throw new ArgumentOutOfRangeException("fftSize must be >= windowSize"); } frameBuffer = new float[fftSize]; fft = FFTFactory.CreateInstance(fftSize); synthesisWindow = WindowUtil.GetFunction(windowType, windowSize, windowNormalizationFactor); }
private void OnWindowStarPower(int id) { var largeLabelStyle = new GUIStyle { fontSize = 20, alignment = TextAnchor.UpperLeft, fontStyle = FontStyle.Bold, normal = new GUIStyleState { textColor = Color.white, } }; GUILayout.Label("Star Power", largeLabelStyle); if (GUILayout.Button("Name Label", settingsButtonStyle)) { settingsOnWindow = OnWindowEdit; settingsCurrentlyEditing = config.StarPowerName; settingsCurrentlyEditingName = "Star Power Name Label"; settingsCurrentBack = OnWindowStarPower; } if (GUILayout.Button("Hit Counter", settingsButtonStyle)) { settingsOnWindow = OnWindowEdit; settingsCurrentlyEditing = config.StarPowersGottenCounter; settingsCurrentlyEditingName = "Star Powers Hit Counter"; settingsCurrentBack = OnWindowStarPower; } if (GUILayout.Button("Total Counter", settingsButtonStyle)) { settingsOnWindow = OnWindowEdit; settingsCurrentlyEditing = config.TotalStarPowersCounter; settingsCurrentlyEditingName = "Total Star Powers Counter"; settingsCurrentBack = OnWindowStarPower; } if (GUILayout.Button("Percentage", settingsButtonStyle)) { settingsOnWindow = OnWindowEdit; settingsCurrentlyEditing = config.StarPowerPercentage; settingsCurrentlyEditingName = "Star Powers Hit Percentage"; settingsCurrentBack = OnWindowStarPower; } if (GUILayout.Button("Current SP", settingsButtonStyle)) { settingsOnWindow = OnWindowEdit; settingsCurrentlyEditing = config.CurrentStarPower; settingsCurrentlyEditingName = "Current SP Percentage"; settingsCurrentBack = OnWindowStarPower; } GUILayout.Space(50.0f); if (GUILayout.Button("Back", settingsButtonStyle)) { settingsOnWindow = OnWindowHead; } GUI.DragWindow(); }
public FftResultStream(FftSize fftSize, WindowFunction windowFunction, MMDevice device) { FftSize = (int)fftSize; Device = device; _fft = new float[(int)fftSize]; _wasapiCapture = CreateWaspiCapture(); var sampleSource = CreateSampleSource(_wasapiCapture); _fftProvider = new CustomFftProvider(sampleSource.WaveFormat.Channels, fftSize, windowFunction); _waveSource = CreateWaveSource(sampleSource, _fftProvider); _buffer = new byte[_waveSource.WaveFormat.BytesPerSecond / 2]; }
static void Prefix(int id, WindowFunction func, GUIContent title) { if (Settings.BlacklistedIMGUIPlugins.Count > 0) { IMGUIBlocker.BlockIfConfigured(func.Method, id); } if (!IMGUIHooks.HooksOverriden) { AutoTranslationPlugin.Current.Hook_TextChanged(title, false); } }
public static double[] Create(WindowFunction Type, int Length) { switch (Type) { case (WindowFunction.rectwin): return(GenerateRectWin(Length)); case (WindowFunction.hann): return(GenerateHann(Length)); } return(new double[Length]); }
public static float[] FFT(float[] values, WindowFunction window = WindowFunction.hanning) { int fftSize = values.Length; if (!IsPowerOfTwo(fftSize)) { throw new ArgumentException("FFT Size must be a power of 2"); } NAudio.Dsp.Complex[] fft_buffer = new NAudio.Dsp.Complex[fftSize]; for (int i = 0; i < fftSize; i++) { fft_buffer[i].X = (float)values[i]; fft_buffer[i].Y = 0; switch (window) { case WindowFunction.none: break; case WindowFunction.hanning: fft_buffer[i].X *= (float)NAudio.Dsp.FastFourierTransform.HammingWindow(i, fftSize); break; case WindowFunction.triangle: fft_buffer[i].X *= (float)TriangleWindow(i, fftSize); break; default: throw new NotImplementedException("unsupported window function"); } } NAudio.Dsp.FastFourierTransform.FFT(true, (int)Math.Log(fftSize, 2.0), fft_buffer); float[] fft = new float[fftSize / 2]; for (int i = 0; i < fft.Length; i++) { var fftL = fft_buffer[i]; var fftR = fft_buffer[fft_buffer.Length - i - 1]; // note that this is different than just taking the absolute value float absL = (float)Math.Sqrt(fftL.X * fftL.X + fftL.Y * fftL.Y); float absR = (float)Math.Sqrt(fftR.X * fftR.X + fftR.Y * fftR.Y); fft[i] = (absL + absR) / 2; } return(fft); }
// pass window parameter to render in sceneviews that are not the active view. public static void Window(GUIContent title, WindowFunction sceneViewFunc, int order, Object target, EditorWindow window = null) { if (Event.current.type != EventType.Layout) { return; } var newWindow = new OverlayWindow(title, sceneViewFunc, order, target) { secondaryOrder = s_Windows.Count, canCollapse = false }; s_Windows.Add(newWindow); }
private void OnWindowTime(int id) { var largeLabelStyle = new GUIStyle { fontSize = 20, alignment = TextAnchor.UpperLeft, fontStyle = FontStyle.Bold, normal = new GUIStyleState { textColor = Color.white, } }; GUILayout.Label("Time", largeLabelStyle); if (GUILayout.Button("Name Label", settingsButtonStyle)) { settingsOnWindow = OnWindowEdit; settingsCurrentlyEditing = config.TimeName; settingsCurrentlyEditingName = "Time Name Label"; settingsCurrentBack = OnWindowTime; } if (GUILayout.Button("Song Time", settingsButtonStyle)) { settingsOnWindow = OnWindowEdit; settingsCurrentlyEditing = config.SongTime; settingsCurrentlyEditingName = "Song Time"; settingsCurrentBack = OnWindowTime; } if (GUILayout.Button("Song Length", settingsButtonStyle)) { settingsOnWindow = OnWindowEdit; settingsCurrentlyEditing = config.SongLength; settingsCurrentlyEditingName = "Song Length"; settingsCurrentBack = OnWindowTime; } if (GUILayout.Button("Song Time Percentage", settingsButtonStyle)) { settingsOnWindow = OnWindowEdit; settingsCurrentlyEditing = config.SongTimePercentage; settingsCurrentlyEditingName = "Song Time Percentage"; settingsCurrentBack = OnWindowTime; } GUILayout.Space(50.0f); if (GUILayout.Button("Back", settingsButtonStyle)) { settingsOnWindow = OnWindowHead; } GUI.DragWindow(); }
private void OnWindowSevenStar(int id) { var largeLabelStyle = new GUIStyle { fontSize = 20, alignment = TextAnchor.UpperLeft, fontStyle = FontStyle.Bold, normal = new GUIStyleState { textColor = Color.white, } }; GUILayout.Label("Seven Star", largeLabelStyle); if (GUILayout.Button("Name Label", settingsButtonStyle)) { settingsOnWindow = OnWindowEdit; settingsCurrentlyEditing = config.SevenStarProgressName; settingsCurrentlyEditingName = "Seven Star Name Label"; settingsCurrentBack = OnWindowSevenStar; } if (GUILayout.Button("Current Score", settingsButtonStyle)) { settingsOnWindow = OnWindowEdit; settingsCurrentlyEditing = config.SevenStarProgressScore; settingsCurrentlyEditingName = "Seven Star Progress Score"; settingsCurrentBack = OnWindowSevenStar; } if (GUILayout.Button("End Score", settingsButtonStyle)) { settingsOnWindow = OnWindowEdit; settingsCurrentlyEditing = config.SevenStarProgressEndScore; settingsCurrentlyEditingName = "Seven Star Progress End Score"; settingsCurrentBack = OnWindowSevenStar; } if (GUILayout.Button("Percentage", settingsButtonStyle)) { settingsOnWindow = OnWindowEdit; settingsCurrentlyEditing = config.SevenStarProgressPercentage; settingsCurrentlyEditingName = "Seven Star Percentage"; settingsCurrentBack = OnWindowSevenStar; } GUILayout.Space(50.0f); if (GUILayout.Button("Back", settingsButtonStyle)) { settingsOnWindow = OnWindowHead; } GUI.DragWindow(); }
/// <summary> /// 初期化メソッド /// </summary> /// <param name="wavedata">波形データ</param> /// <param name="size">サンプルした波形のサイズ</param> /// <param name="func">窓関数の種類</param> private void Initialize(double[] wavedata, int size, WindowFunction func) { use = (uint)size; this.size = NextPow2((uint)size); verbose = false; //スペクトル幅設定 spectrumWidth = 512.0 / (double)this.size; //リスト生成 waveArray = new List <double>(wavedata); fftArray = new List <Complex>((int)this.size); window = new List <double>(); windowWave = new List <double>(); WindowFunctionGenerate(func); //窓関数をかけた波を生成 FastFourierTransform(false); //通常のFFT }
public override async Task OnActivateAsync() { List <Task> t = new List <Task>(); streamProvider = GetStreamProvider("SMSProvider"); jobManager = GrainFactory.GetGrain <IJobManagerGrain>(0, "JobManager"); var window = await jobManager.GetWindow(this.GetPrimaryKey()); window_length = window.Item1; window_slide = window.Item2; data1 = new SortedList <long, List <MyType> >(); data2 = new SortedList <long, List <MyType> >(); func1 = new WindowFunction(window_length, window_slide); func2 = new WindowFunction(window_length, window_slide); // ask the JobManager which streams it should subscribe var subscribe = await jobManager.GetTwoSourceSubscribe(this.GetPrimaryKey()); /********** Handle the first source stream*************************/ var stream1 = streamProvider.GetStream <MyType>(subscribe.Item1, null); var subscriptionHandles1 = await stream1.GetAllSubscriptionHandles(); if (subscriptionHandles1.Count > 0) { foreach (var subscriptionHandle in subscriptionHandles1) { await subscriptionHandle.ResumeAsync(Process1); } } t.Add(stream1.SubscribeAsync(Process1)); /********** Handle the second source stream************************/ var stream2 = streamProvider.GetStream <MyType>(subscribe.Item2, null); var subscriptionHandles2 = await stream2.GetAllSubscriptionHandles(); if (subscriptionHandles2.Count > 0) { foreach (var subscriptionHandle in subscriptionHandles2) { await subscriptionHandle.ResumeAsync(Process2); } } t.Add(stream2.SubscribeAsync(Process2)); await Task.WhenAll(t); }
public void Render(IPEGI target, WindowFunction doWindow, string c_windowName) { ef.ResetInspectionTarget(target); _function = doWindow; if (UseWindow) { _windowRect.x = Mathf.Clamp(_windowRect.x, 0, Screen.width - 10); _windowRect.y = Mathf.Clamp(_windowRect.y, 0, Screen.height - 10); _windowRect = GUILayout.Window(0, _windowRect, DrawFunctionWrapper, c_windowName, GUILayout.MaxWidth(360 * upscale), GUILayout.ExpandWidth(true)); } else { DrawFunctionWrapper(0); } }
public static Rect Window(int id, Rect clientRect, WindowFunction func, string text, GUIStyle style){}
internal static void CallWindowDelegate(WindowFunction func, int id, GUISkin _skin, int forceRect, float width, float height, GUIStyle style) { GUILayoutUtility.SelectIDList(id, true); GUISkin skin = GUI.skin; if (Event.current.type == EventType.Layout) { if (forceRect != 0) { GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(width), GUILayout.Height(height) }; GUILayoutUtility.BeginWindow(id, style, options); } else { GUILayoutUtility.BeginWindow(id, style, null); } } GUI.skin = _skin; func(id); if (Event.current.type == EventType.Layout) { GUILayoutUtility.Layout(); } GUI.skin = skin; }
private static Rect DoWindow(int id, Rect clientRect, WindowFunction func, GUIContent title, GUIStyle style, GUISkin skin, bool forceRectOnLayout) { return INTERNAL_CALL_DoWindow(id, ref clientRect, func, title, style, skin, forceRectOnLayout); }
public int flake_set_defaults(int lvl) { compression = lvl; if ((lvl < 0 || lvl > 12) && (lvl != 99)) { return -1; } // default to level 5 params window_function = WindowFunction.Flattop | WindowFunction.Tukey; do_midside = true; block_size = 0; block_time_ms = 100; min_fixed_order = 0; max_fixed_order = 4; min_prediction_order = 1; max_prediction_order = 12; min_partition_order = 0; max_partition_order = 8; variable_block_size = 0; lpc_min_precision_search = 0; lpc_max_precision_search = 0; orders_per_channel = 32; do_seektable = true; do_wasted = true; do_constant = true; estimate_window = false; // differences from level 7 switch (lvl) { case 0: do_constant = false; do_wasted = false; do_midside = false; window_function = WindowFunction.Bartlett; orders_per_window = 1; max_prediction_order = 7; min_fixed_order = 3; max_fixed_order = 2; break; case 1: do_constant = false; do_wasted = false; do_midside = false; window_function = WindowFunction.Bartlett; orders_per_window = 1; min_fixed_order = 2; max_fixed_order = 2; max_prediction_order = 7; break; case 2: do_constant = false; do_midside = false; window_function = WindowFunction.Bartlett; orders_per_window = 1; min_fixed_order = 2; max_fixed_order = 2; max_prediction_order = 8; break; case 3: do_constant = false; min_fixed_order = 2; max_fixed_order = 2; orders_per_window = 1; orders_per_channel = 1; max_prediction_order = 8; break; case 4: do_constant = false; min_fixed_order = 2; max_fixed_order = 2; orders_per_window = 2; orders_per_channel = 2; max_prediction_order = 8; break; case 5: do_constant = false; min_fixed_order = 2; max_fixed_order = 2; orders_per_window = 4; orders_per_channel = 4; max_prediction_order = 8; break; case 6: do_constant = false; min_fixed_order = 2; max_fixed_order = 2; orders_per_window = 2; orders_per_channel = 2; break; case 7: do_constant = false; min_fixed_order = 2; max_fixed_order = 2; orders_per_window = 4; orders_per_channel = 4; break; case 8: orders_per_window = 8; orders_per_channel = 8; break; case 9: min_fixed_order = 2; max_fixed_order = 2; orders_per_window = 4; orders_per_channel = 4; max_prediction_order = 32; break; case 10: min_fixed_order = 2; max_fixed_order = 2; orders_per_window = 7; max_prediction_order = 32; break; case 11: min_fixed_order = 2; max_fixed_order = 2; orders_per_window = 11; max_prediction_order = 32; break; } return 0; }
public int flake_set_defaults(int lvl) { compression = lvl; if ((lvl < 0 || lvl > 12) && (lvl != 99)) { return -1; } // default to level 5 params window_function = WindowFunction.Flattop | WindowFunction.Tukey; order_method = OrderMethod.Akaike; stereo_method = StereoMethod.Evaluate; window_method = WindowMethod.Evaluate; block_size = 0; block_time_ms = 105; prediction_type = PredictionType.Search; min_prediction_order = 1; max_prediction_order = 12; estimation_depth = 1; min_fixed_order = 2; max_fixed_order = 2; min_partition_order = 0; max_partition_order = 8; variable_block_size = 0; lpc_min_precision_search = 1; lpc_max_precision_search = 1; do_seektable = true; // differences from level 7 switch (lvl) { case 0: block_time_ms = 53; prediction_type = PredictionType.Fixed; stereo_method = StereoMethod.Independent; max_partition_order = 6; break; case 1: prediction_type = PredictionType.Levinson; stereo_method = StereoMethod.Independent; window_function = WindowFunction.Bartlett; max_prediction_order = 8; max_partition_order = 6; break; case 2: stereo_method = StereoMethod.Independent; window_function = WindowFunction.Bartlett; max_partition_order = 6; break; case 3: stereo_method = StereoMethod.Estimate; window_function = WindowFunction.Bartlett; max_prediction_order = 8; break; case 4: stereo_method = StereoMethod.Estimate; window_function = WindowFunction.Bartlett; break; case 5: stereo_method = StereoMethod.Estimate; window_method = WindowMethod.Estimate; break; case 6: stereo_method = StereoMethod.Estimate; break; case 7: break; case 8: estimation_depth = 2; min_fixed_order = 0; lpc_min_precision_search = 0; break; case 9: window_function = WindowFunction.Bartlett; max_prediction_order = 32; break; case 10: min_fixed_order = 0; max_fixed_order = 4; max_prediction_order = 32; //lpc_max_precision_search = 2; break; case 11: min_fixed_order = 0; max_fixed_order = 4; max_prediction_order = 32; estimation_depth = 5; //lpc_max_precision_search = 2; variable_block_size = 4; break; } return 0; }
/// <summary> /// ローパスフィルタを作成 /// </summary> /// <param name="n">タップ数=2n+1</param> /// <param name="w">遮断周波数</param> /// <param name="window">窓関数</param> public LowPassFir(int n, double w, WindowFunction window) : base(n) { FirCommon.CalcLinearBPFCoefficient(FirCommon.FirFilterType.LPF, this.coef, w, 0, window); }
/// <summary> /// バンドパスフィルタを作成 /// </summary> /// <param name="n">タップ数=2n+1</param> /// <param name="wl">下限周波数</param> /// <param name="wh">上限周波数</param> /// <param name="window">窓関数</param> public BandPassFir(int n, double wl, double wh, WindowFunction window) : base(n) { FirCommon.CalcLinearBPFCoefficient(FirCommon.FirFilterType.BPF, this.coef, (wl - wh)/2, (wl + wh)/2, window); }
public static Rect Window(int id, Rect screenRect, WindowFunction func, Texture image, GUIStyle style, GUILayoutOption[] options){}
public static Rect Window(int id, Rect screenRect, WindowFunction func, string text, GUIStyle style, GUILayoutOption[] options){}
public static Rect Window(int id, Rect screenRect, WindowFunction func, GUIContent content, GUILayoutOption[] options){}
private static Rect INTERNAL_CALL_DoWindow(int id, ref Rect clientRect, WindowFunction func, GUIContent title, GUIStyle style, GUISkin skin, bool forceRectOnLayout){}
internal static void CallWindowDelegate(WindowFunction func, int id, GUISkin _skin, int forceRect, float width, float height, GUIStyle style){}
public static Rect Window(int id, Rect clientRect, WindowFunction func, GUIContent title, GUIStyle style){}
public static Rect Window(int id, Rect clientRect, WindowFunction func, Texture image, GUIStyle style){}
}//GetOddLinearBPFCoefficient /// <summary> /// 線形位相バンドパスフィルタ(奇数タップ)の係数を計算する。 /// 右側半分のみを計算。 /// </summary> /// <param name="type">フィルタタイプ</param> /// <param name="coef">係数の格納先</param> /// <param name="w">遮断周波数(BPF の場合は遮断帯域幅、HPF の場合は π-遮断周波数)</param> /// <param name="w0">(BPF のみ) 中心周波数</param> /// <param name="window">窓関数</param> public static void CalcEvenLinearBPFCoefficient(FirFilterType type, double[] coef, double w, double w0, WindowFunction window) { int n = coef.Length - 1; double sum; sum = 0; for(int i=0; i<=n; ++i) { double x = i + 0.5; double tmp = window(x) * Math.Sin(w * x) / x; sum += tmp * 2; if(type == FirFilterType.LPF) { coef[n - i] = tmp; } else if(type == FirFilterType.HPF) { if(i%2 != 0) coef[n - i] = -tmp; else coef[n - i] = tmp; } else { coef[n - i] = 2 * Math.Cos(w0 * x) * tmp; } } for(int i=0; i<n; ++i) { coef[i] /= sum; } }//GetEvenLinearBPFCoefficient
public void windowFunction(WindowFunction whichFunction, int numSamples, float[] input) { if (whichFunction == WindowFunction.BARTLETT) { // Bartlett (triangular) window for (int i = 0; i < numSamples / 2; ++i) { input[i] *= (float)(i / (numSamples / 2)); input[i + (numSamples / 2)] *= (float)(1 - (i / (numSamples / 2))); } } if (whichFunction == WindowFunction.HAMMING) { // Hamming for (int i = 0; i < numSamples; ++i) input[i] *= (float)(0.54 - 0.46 * Math.Cos(2 * Math.PI * i / (numSamples - 1))); } if (whichFunction == WindowFunction.HANNING) { // Hanning for (int i = 0; i < numSamples; ++i) input[i] *= (float)(0.50 - 0.50 * Math.Cos(2 * Math.PI * i / (numSamples - 1))); } if (whichFunction == WindowFunction.BLACKMAN) { // Blackman for (int i = 0; i < numSamples; ++i) input[i] *= (float)(0.42 - 0.5 * Math.Cos(2 * Math.PI * i / (numSamples - 1)) + 0.08 * Math.Cos(4 * Math.PI * i / (numSamples - 1))); } }
private static Rect DoWindow(int id, Rect screenRect, WindowFunction func, GUIContent content, GUIStyle style, GUILayoutOption[] options){}
/// <summary> /// ハイパスフィルタを作成 /// </summary> /// <param name="n">タップ数=2n+1</param> /// <param name="w">遮断周波数</param> /// <param name="window">窓関数</param> public HighPassFir(int n, double w, WindowFunction window) : base(n) { FirCommon.CalcLinearBPFCoefficient(FirCommon.FirFilterType.HPF, this.coef, Math.PI - w, 0, window); }
/// <summary> /// パラメータを設定する。 /// </summary> /// <param name="wl">下限周波数</param> /// <param name="wh">上限周波数</param> /// <param name="window">窓関数</param> public void SetParameter(double wl, double wh, WindowFunction window) { FirCommon.CalcOddLinearBPFCoefficient(FirFilterType.BPF, this.coef, (wl - wh)/2, (wl + wh)/2, window); }
unsafe void calculate_window(float* window, window_function func, WindowFunction flag) { if ((eparams.window_function & flag) == 0 || _windowcount == lpc.MAX_LPC_WINDOWS) return; int sz = _windowsize; float* pos1 = window + _windowcount * Flake.MAX_BLOCKSIZE * 2; float* pos = pos1; do { func(pos, sz); if ((sz & 1) != 0) break; pos += sz; sz >>= 1; } while (sz >= 32); double scale = 0.0; for (int i = 0; i < _windowsize; i++) scale += pos1[i] * pos1[i]; windowScale[_windowcount] = scale; _windowcount++; }
public static Rect Window (int id, Rect screenRect, WindowFunction func, Texture image, params GUILayoutOption[] options) { return new Rect (); }
public static Rect Window (int id, Rect screenRect, WindowFunction func, GUIContent content, GUIStyle style, params GUILayoutOption[] options) { return new Rect (); }
/// <summary> /// バンドパスフィルタを作成 /// </summary> /// <param name="n">タップ数=2n+1</param> /// <param name="wl">下限周波数</param> /// <param name="wh">上限周波数</param> /// <param name="window">窓関数</param> public BandPassFir(int n, double wl, double wh, WindowFunction window) : base(n) { this.SetParameter(wl, wh, window); }
unsafe void calculate_window(FLACCLTask task, window_function func, WindowFunction flag) { if ((eparams.window_function & flag) == 0 || task.nWindowFunctions == lpc.MAX_LPC_WINDOWS) return; func(((float*)task.clWindowFunctionsPtr) + task.nWindowFunctions * task.frameSize, task.frameSize); //int sz = _windowsize; //float* pos = window + _windowcount * FLACCLWriter.MAX_BLOCKSIZE * 2; //do //{ // func(pos, sz); // if ((sz & 1) != 0) // break; // pos += sz; // sz >>= 1; //} while (sz >= 32); task.nWindowFunctions++; }
/// <summary> /// パラメータを設定する。 /// </summary> /// <param name="w">遮断周波数</param> /// <param name="window">窓関数</param> public void SetParameter(double w, WindowFunction window) { FirCommon.CalcOddLinearBPFCoefficient(FirFilterType.HPF, this.coef, Math.PI - w, 0, window); }
private static Rect DoModalWindow(int id, Rect clientRect, WindowFunction func, GUIContent content, GUIStyle style, GUISkin skin) { return INTERNAL_CALL_DoModalWindow(id, ref clientRect, func, content, style, skin); }
/// <summary> /// ハイパスフィルタを作成 /// </summary> /// <param name="n">タップ数=2n+1</param> /// <param name="w">遮断周波数</param> /// <param name="window">窓関数</param> public HighPassFir(int n, double w, WindowFunction window) : base(n) { this.SetParameter(w, window); }
public static Rect Window(int id, Rect clientRect, WindowFunction func, GUIContent content){}
public static Rect Window(int id, Rect clientRect, WindowFunction func, string text){}