コード例 #1
0
    public override void OnInspectorGUI()
    {
        dsp = (DSPModule)target;

        serializedObject.Update();
        EditorGUILayout.Space();
        dsp.module = (DSPModule.Modules)EditorGUILayout.EnumPopup(dsp.module);

        if (dsp.module == DSPModule.Modules.Oscillator)
        {
            ShowOscillator();
        }
        else if (dsp.module == DSPModule.Modules.Noise)
        {
            ShowNoise();
        }
        else if (dsp.module == DSPModule.Modules.Sampler)
        {
            ShowSampler();
        }

        else if (dsp.module == DSPModule.Modules.Delay)
        {
            ShowDelay();
        }
        else if (dsp.module == DSPModule.Modules.Envelope)
        {
            ShowEnvelope();
        }
        else if (dsp.module == DSPModule.Modules.Gain)
        {
            ShowGain();
        }
        serializedObject.ApplyModifiedProperties();
    }
コード例 #2
0
            /// <summary>
            /// Test
            /// </summary>
            static void Test_PlayWithSATools()
            {
                string audioFileName    = "./test.ogg";
                string dspPluginDllName = "dsp_stereo_tool.dll";

                // Load plugin
                var ProgramFilesPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
                var pluginDllPath    = Path.Combine(ProgramFilesPath, "Winamp/Plugins/" + dspPluginDllName);

                Console.WriteLine("Loading: " + pluginDllPath);
                DSPPlugin dsp = DSPPluginLoader.LoadDSPPlugin(pluginDllPath, IntPtr.Zero);

                if (dsp == null || dsp.Modules == null || dsp.Modules.Count == 0)
                {
                    Console.WriteLine(" - Error on LoadDSPPlugin(...)");
                    return;
                }

                DSPModule mod = dsp.Modules[0];

                Console.WriteLine(" + Plug-in: " + dsp.Description);
                Console.WriteLine(" + Header version: " + dsp.DspHeaderVersion);
                Console.WriteLine(" + Module: " + mod.Description);

                // Initialize Plugin
                int initResult = mod.Init();

                if (initResult != 0)
                {
                    Console.WriteLine(" - Error on mod.Init(...)");
                    return;
                }

                using (OggDecodeStream waveStream = new OggDecodeStream(File.OpenRead(audioFileName)))
                    using (WaveOut waveOut = new WaveOut(-1, waveStream.SamplesPerSecond, waveStream.BitsPerSample, waveStream.Channels))
                    {
                        var bytesPerSample = waveStream.BitsPerSample / 8 * waveStream.Channels;

                        // Create waveform buffer (and get pinned pointer)
                        byte[]   buffer       = new byte[bytesPerSample * 4096];
                        GCHandle bufferHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
                        IntPtr   pBuffer      = bufferHandle.AddrOfPinnedObject();

                        while (true)
                        {
                            // read (to half of buffer)
                            int read = waveStream.Read(buffer, 0, buffer.Length / 2);
                            if (read == 0)
                            {
                                break;
                            }

                            // modify by dsp
                            int samplesWritten = mod.ModifySample(pBuffer,
                                                                  read / bytesPerSample, waveStream.BitsPerSample,
                                                                  waveStream.Channels, waveStream.SamplesPerSecond);

                            // write
                            waveOut.Write(buffer, 0, samplesWritten * bytesPerSample);
                            while (waveOut.EnqueuedBufferSize >= buffer.Length * 4)
                            {
                                System.Windows.Forms.Application.DoEvents();
                                System.Threading.Thread.Sleep(1);
                            }
                        }

                        // release buffer
                        pBuffer = IntPtr.Zero;
                        bufferHandle.Free();
                    }

                mod.Quit();
                dsp.Release();
            }