Exemplo n.º 1
0
        public PianoSynth()
        {
            mixer = new WaveMixerStream32();
            mixer.AutoStop = false;

            int i = 0;
            foreach (var note in noteFiles)
            {
                reader[i] = new WaveFileReader(note);

                offsetStream[i] = new WaveOffsetStream(reader[i]);
                channelSteam[i] = new WaveChannel32(offsetStream[i]);
                channelSteam[i].Position = channelSteam[i].Length;
                mixer.AddInputStream(channelSteam[i]);

                i++;
            }

            if (waveOutDevice == null)
            {
                waveOutDevice = new WaveOut {DeviceNumber = 0};
                waveOutDevice.Init(mixer);
                waveOutDevice.Volume = 0;
                waveOutDevice.Play();
                waveOutDevice.Volume = 100;
            }
        }
Exemplo n.º 2
0
        public frmMixTest()
        {
            //Setup the Mixer

            mixer = new WaveMixerStream32();
            mixer.AutoStop = false;
        }
Exemplo n.º 3
0
        public TestMix()
        {
            //WaveStream str1 = new Mp3FileReader("C:\\Users\\mtemkine\\Desktop\\snd\\guitar1.mp3");
            //WaveStream str2 = new Mp3FileReader("C:\\Users\\mtemkine\\Desktop\\snd\\molecules.mp3");
            //WaveMixerStream32 mix = new WaveMixerStream32(new [] {str1, str2}, false);

            var background = new Mp3FileReader("C:\\Users\\mtemkine\\Desktop\\snd\\ferriss.mp3");
            var message = new Mp3FileReader("C:\\Users\\mtemkine\\Desktop\\snd\\guitar1.mp3");

            var mixer = new WaveMixerStream32();
            mixer.AutoStop = true;

            var messageOffset = background.TotalTime;
            var messageOffsetted = new WaveOffsetStream(message, TimeSpan.FromSeconds(1.5), TimeSpan.Zero, message.TotalTime.Subtract(TimeSpan.FromSeconds(1)));

            var background32 = new WaveChannel32(background);
            background32.PadWithZeroes = false;
            background32.Volume = 0.9f;

            var message32 = new WaveChannel32(messageOffsetted);
            message32.PadWithZeroes = false;
            message32.Volume = 0.7f;

            var s1 = new RawSourceWaveStream(background32, new WaveFormat(8000, 16, 1));
            var s2 = new RawSourceWaveStream(message32, new WaveFormat(8000, 16, 1));
            WaveFormat targetFormat = WaveFormat.CreateIeeeFloatWaveFormat(128, 2);
            var ss1 = new WaveFormatConversionStream(targetFormat, background32);
            //var c = new WaveFormatConversionStream(WaveFormat.CreateALawFormat(8000, 1), background32);
            //var stream_background32 = new WaveFormatConversionStream(new WaveFormat(256, 32, 2), background32);
            //var stream_message32 = new WaveFormatConversionStream(new WaveFormat(256, 32, 2), message32);
            mixer.AddInputStream(s1);
            mixer.AddInputStream(s2);

            WaveFileWriter.CreateWaveFile("mycomposed.wav", new Wave32To16Stream(mixer));
        }
Exemplo n.º 4
0
        private static void AddIntroOutro(string SermonFileName = "",
            string IntroFileName = "",
            string OutroFileName = "",
            double StartSermonTime = 0,
            double StartOutroTime = 0,
            string ResultingFile = "")
        {
            if (String.IsNullOrWhiteSpace(SermonFileName)) throw new ArgumentException("SermonFileName must reference a valid file.");

            if (String.IsNullOrWhiteSpace(IntroFileName)) throw new ArgumentException("IntroFileName must reference a valid file.");

            if (String.IsNullOrWhiteSpace(OutroFileName)) throw new ArgumentException("OutroFileName must reference a valid file.");

            if (String.IsNullOrWhiteSpace(ResultingFile)) ResultingFile = Settings.Default.IntroOutroDirectory;

            WaveFileReader intro = new WaveFileReader(IntroFileName);
            WaveFileReader outro = new WaveFileReader(OutroFileName);
            WaveFileReader audio = new WaveFileReader(SermonFileName);

            WaveMixerStream32 mixer = new WaveMixerStream32();
            //mixer.AutoStop;

            WaveOffsetStream audioOffsetted = new WaveOffsetStream(
                audio,
                TimeSpan.FromSeconds(StartSermonTime), //N seconds after start of intro.
                TimeSpan.Zero,
                audio.TotalTime);

            TimeSpan outroOffset = TimeSpan.FromSeconds(StartSermonTime) + audio.TotalTime - TimeSpan.FromSeconds(StartOutroTime);

            WaveOffsetStream outroOffsetted = new WaveOffsetStream(
               outro,
               outroOffset,
               TimeSpan.Zero,
               outro.TotalTime);

            WaveChannel32 intro32 = new WaveChannel32(intro);
            intro32.PadWithZeroes = false;
            mixer.AddInputStream(intro32);

            WaveChannel32 outro32 = new WaveChannel32(outroOffsetted);
            outro32.PadWithZeroes = false;
            mixer.AddInputStream(outro32);

            WaveChannel32 audio32 = new WaveChannel32(audioOffsetted);
            audio32.PadWithZeroes = false;
            mixer.AddInputStream(audio32);

            FileInfo file = new FileInfo(SermonFileName);
            if (!Directory.Exists(ResultingFile)) Directory.CreateDirectory(ResultingFile);

            string FileOut = String.Format(@"{0}\{1}", ResultingFile, file.Name);

            WaveFileWriter.CreateWaveFile(FileOut, new Wave32To16Stream(mixer));
        }
Exemplo n.º 5
0
        public MixDiffForm()
        {
            InitializeComponent();
            mixer = new WaveMixerStream32();
            mixer.AutoStop = false;
            skipSeconds = 3;
            fileButtons = new List<Button>();
            fileButtons.Add(buttonA);
            fileButtons.Add(buttonB);
            fileButtons.Add(buttonC);
            fileButtons.Add(buttonD);

        }
Exemplo n.º 6
0
        /// <summary>
        /// Setup Audio via NAudio. Defaults to using Asio for Audio Output.
        /// </summary>
        public void SetupAudio()
        {
            //Setup the Mixer
            mixer = new WaveMixerStream32();
            mixer.AutoStop = false;

            if (waveOutDevice == null)
            {
                //waveOutDevice = new AsioOut();

                waveOutDevice = new WaveOut(0, 300, false);
                
                waveOutDevice.Init(mixer);
                waveOutDevice.Play();
            }
        }
Exemplo n.º 7
0
        static Audio()
        {
            if (!initialized)
            {
#if WINDOWS
                try
                {
                    mixer = new WaveMixerStream32();
                    mixer.AutoStop = false;

                    waveOutDevice = new DirectSoundOut(50);
                    waveOutDevice.Init(mixer);

                    initialized = true;
                }
                catch (Exception driverCreateException)
                {
                    Console.WriteLine(String.Format("{0}", driverCreateException.Message));
                    return;
                }
#endif
            }
        }
Exemplo n.º 8
0
        public override int Read(byte[] buffer, int offset, int count)
        {
            if (this.AutoStop && this.position + (long)count > this.length)
            {
                count = (int)(this.length - this.position);
            }
            if (count % this.bytesPerSample != 0)
            {
                throw new ArgumentException("Must read an whole number of samples", "count");
            }
            Array.Clear(buffer, offset, count);
            int val = 0;

            byte[] array = new byte[count];
            lock (this.inputsLock)
            {
                foreach (WaveStream waveStream in this.inputStreams)
                {
                    if (waveStream.HasData(count))
                    {
                        int num = waveStream.Read(array, 0, count);
                        val = Math.Max(val, num);
                        if (num > 0)
                        {
                            WaveMixerStream32.Sum32BitAudio(buffer, offset, array, num);
                        }
                    }
                    else
                    {
                        val = Math.Max(val, count);
                        waveStream.Position += (long)count;
                    }
                }
            }
            this.position += (long)count;
            return(count);
        }
Exemplo n.º 9
0
        public void Init(Map map)
        {
            if (waveOutDevice != null)
            {
                waveOutDevice.Stop();
                waveOutDevice.Dispose();

                mixer.Close();
            }

            OpenMidiFile();

            mixer = new WaveMixerStream32();
            mixer.AutoStop = true;

            waveOutDevice = new NAudio.Wave.DirectSoundOut();
            //waveOutDevice = new NAudio.Wave.AsioOut();

            waveOutDevice.Init(mixer);

            int countSample = 0;
            map.Channels.ForEach(c => c.ListSample.ForEach(s => countSample++));
            countSample *= CountInstancePerSample;

            reader = new WaveStream[countSample];
            offsetStream = new EffectStream[countSample];
            channelSteam = new WaveChannel32[countSample];
            PlayingNote = new bool[countSample];
            dicSample = new Dictionary<String, List<int>>();
            dicEffect = new Dictionary<String, List<List<Effect>>>();

            LoadSample(map);

            waveOutDevice.Play();
            mixer.Position = long.MaxValue;
            mixer.AutoStop = false;

            CreateMidi();
        }
Exemplo n.º 10
0
        private byte[] RealMix(ReceivedRtp item1, ReceivedRtp item2)
        {
            if (item1 == null || item2 == null) return null;

            if (item1.size == 0 || item2.size == 0) return null;

            byte[] wavSrc1 = new byte[item1.size - headersize];
            byte[] wavSrc2 = new byte[item2.size - headersize];

            Array.Copy(item1.buff, headersize, wavSrc1, 0, (item1.size - headersize));
            Array.Copy(item2.buff, headersize, wavSrc2, 0, (item2.size - headersize));

            WaveMixerStream32 mixer = new WaveMixerStream32();
            // mixer.AutoStop = true;
            MemoryStream memstrem = new MemoryStream(wavSrc1);
            RawSourceWaveStream rawsrcstream = new RawSourceWaveStream(memstrem, this.codec);
            WaveFormatConversionStream conversionstream = new WaveFormatConversionStream(pcmFormat16, rawsrcstream);
            WaveChannel32 channelstream = new WaveChannel32(conversionstream);
            mixer.AddInputStream(channelstream);

            memstrem = new MemoryStream(wavSrc2);
            rawsrcstream = new RawSourceWaveStream(memstrem, this.codec);
            conversionstream = new WaveFormatConversionStream(pcmFormat16, rawsrcstream);
            channelstream = new WaveChannel32(conversionstream);
            mixer.AddInputStream(channelstream);
            mixer.Position = 0;

            Wave32To16Stream to16 = new Wave32To16Stream(mixer);
            var convStm = new WaveFormatConversionStream(pcmFormat8, to16);
            byte[] mixedbytes = new byte[(int)convStm.Length];
            int chk = convStm.Read(mixedbytes, 0, (int)convStm.Length);
            //Buffer.BlockCopy(tobyte, 0, writingBuffer, 0, tobyte.Length);

            memstrem.Close();
            rawsrcstream.Close();
            conversionstream.Close();
            channelstream.Close();

            convStm.Close(); convStm.Dispose(); convStm = null;
            to16.Close(); to16.Dispose(); to16 = null;
            mixer.Close(); mixer.Dispose(); mixer = null;

            return mixedbytes;
        }
Exemplo n.º 11
0
        private void ProcessMixing2(RcvData data, int dataSize)
        {
            string processingFn = string.Format("d:\\{0}_{1}_{2}.wav", data.seqnum, data.extension, data.peernumber);

            List<RecInfos> ls0 = lExtension0.FindAll(
                        delegate(RecInfos list)
                        {
                            return list.rcvData.Equals(data) && list.isExtension == 0;
                        });

            List<RecInfos> ls1 = lExtension1.FindAll(
                        delegate(RecInfos list)
                        {
                            return list.rcvData.Equals(data) && list.isExtension == 1;
                        });

            IsExtensionComparer isExtensionCompare = new IsExtensionComparer();
            ls0.Sort(isExtensionCompare);
            ls1.Sort(isExtensionCompare);

            int count = 0;
            int count0 = ls0.Count();
            int count1 = ls1.Count();

            if (count0 - count1 < 0)
                count = count0;
            else
                count = count1;

            byte[] buffWriting = new byte[320 * count];

            for (int i = 0; i < count; i++)
            {
                if (ls0[i].seq == ls1[i].seq)
                {
                    // 믹싱
                    // 코덱 종류에 따라서 바이트 길이는 달라질 수 있다. 실제로 만들 때 경우의 수 확인하고 만들어야 한다.
                    byte[] wavSrc0 = new byte[160];
                    byte[] wavSrc1 = new byte[160];

                    Array.Copy(ls0[i].voice, 12, wavSrc0, 0, wavSrc0.Length);
                    Array.Copy(ls1[i].voice, 12, wavSrc1, 0, wavSrc1.Length);

                    WaveMixerStream32 mixer = new WaveMixerStream32();
                    //mixer.AutoStop = true;

                    WaveChannel32 channelStm = null;

                    MemoryStream memStm = null;
                    BufferedStream bufStm = null;
                    RawSourceWaveStream rawSrcStm = null;
                    WaveFormatConversionStream conversionStm = null;

                    for (int j = 0; j < 2; j++)
                    {
                        if (j == 0)
                            memStm = new MemoryStream(wavSrc0);
                        else
                            memStm = new MemoryStream(wavSrc1);

                        bufStm = new BufferedStream(memStm);
                        rawSrcStm = new RawSourceWaveStream(bufStm, mulawFormat);
                        conversionStm = new WaveFormatConversionStream(pcmFormat, rawSrcStm);

                        channelStm = new WaveChannel32(conversionStm);
                        mixer.AddInputStream(channelStm);
                    }
                    mixer.Position = 0;

                    Wave32To16Stream to16 = new Wave32To16Stream(mixer);
                    var convStm = new WaveFormatConversionStream(pcmFormat, to16);
                    byte[] tobyte = new byte[(int)convStm.Length];
                    int chk = convStm.Read(tobyte, 0, (int)convStm.Length);
                    Buffer.BlockCopy(tobyte, 0, buffWriting, i * tobyte.Length, tobyte.Length);

                    conversionStm.Close();
                    rawSrcStm.Close();
                    bufStm.Close();
                    memStm.Close();

                    convStm.Close();
                    to16.Close();
                    channelStm.Close();
                    mixer.Close();

                    // 삭제
                    lExtension0.Remove(ls0[i]);
                    lExtension1.Remove(ls1[i]);
                }
                else if (ls0[i].seq - ls1[i].seq < 0)
                {
                    // ls0 만 믹싱
                    // ls0 원본에 byte[] 붙임 > 원본 byte[]를 wavesream 으로 변환 > wave 파일로 저장

                    // 믹싱
                    // 코덱 종류에 따라서 바이트 길이는 달라질 수 있다. 실제로 만들 때 경우의 수 확인하고 만들어야 한다.
                    byte[] wavSrc0 = new byte[160];
                    byte[] wavSrc1 = new byte[160];

                    Array.Copy(ls0[i].voice, 12, wavSrc0, 0, wavSrc0.Length);
                    Array.Copy(ls1[i].voice, 12, wavSrc1, 0, wavSrc1.Length);

                    WaveMixerStream32 mixer = new WaveMixerStream32();
                    //mixer.AutoStop = true;

                    WaveChannel32 channelStm = null;

                    MemoryStream memStm = null;
                    BufferedStream bufStm = null;
                    RawSourceWaveStream rawSrcStm = null;
                    WaveFormatConversionStream conversionStm = null;

                    for (int j = 0; j < 2; j++)
                    {
                        if (j == 0)
                            memStm = new MemoryStream(wavSrc0);
                        else
                            memStm = new MemoryStream(wavSrc1);

                        bufStm = new BufferedStream(memStm);
                        rawSrcStm = new RawSourceWaveStream(bufStm, mulawFormat);
                        conversionStm = new WaveFormatConversionStream(pcmFormat, rawSrcStm);

                        channelStm = new WaveChannel32(conversionStm);
                        mixer.AddInputStream(channelStm);
                    }
                    mixer.Position = 0;

                    Wave32To16Stream to16 = new Wave32To16Stream(mixer);
                    var convStm = new WaveFormatConversionStream(pcmFormat, to16);
                    byte[] tobyte = new byte[(int)convStm.Length];
                    int chk = convStm.Read(tobyte, 0, (int)convStm.Length);
                    Buffer.BlockCopy(tobyte, 0, buffWriting, i * tobyte.Length, tobyte.Length);

                    conversionStm.Close();
                    rawSrcStm.Close();
                    bufStm.Close();
                    memStm.Close();

                    convStm.Close();
                    to16.Close();
                    channelStm.Close();
                    mixer.Close();

                    // 삭제
                    lExtension0.Remove(ls0[i]);
                    ls1.Insert(i + 1, ls1[i]);
                }
                else if (ls0[i].seq - ls1[i].seq > 0)
                {
                    // ls1 만 믹싱
                    // ls1 원본에 byte[] 붙임 > 원본 byte[]를 wavesream 으로 변환 > wave 파일로 저장

                    // 믹싱
                    // 코덱 종류에 따라서 바이트 길이는 달라질 수 있다. 실제로 만들 때 경우의 수 확인하고 만들어야 한다.
                    byte[] wavSrc0 = new byte[160];
                    byte[] wavSrc1 = new byte[160];

                    Array.Copy(ls0[i].voice, 12, wavSrc0, 0, wavSrc0.Length);
                    Array.Copy(ls1[i].voice, 12, wavSrc1, 0, wavSrc1.Length);

                    WaveMixerStream32 mixer = new WaveMixerStream32();
                    //mixer.AutoStop = true;

                    WaveChannel32 channelStm = null;

                    MemoryStream memStm = null;
                    BufferedStream bufStm = null;
                    RawSourceWaveStream rawSrcStm = null;
                    WaveFormatConversionStream conversionStm = null;

                    for (int j = 0; j < 2; j++)
                    {
                        if (j == 0)
                            memStm = new MemoryStream(wavSrc0);
                        else
                            memStm = new MemoryStream(wavSrc1);

                        bufStm = new BufferedStream(memStm);
                        rawSrcStm = new RawSourceWaveStream(bufStm, mulawFormat);
                        conversionStm = new WaveFormatConversionStream(pcmFormat, rawSrcStm);

                        channelStm = new WaveChannel32(conversionStm);
                        mixer.AddInputStream(channelStm);
                    }
                    mixer.Position = 0;

                    Wave32To16Stream to16 = new Wave32To16Stream(mixer);
                    var convStm = new WaveFormatConversionStream(pcmFormat, to16);
                    byte[] tobyte = new byte[(int)convStm.Length];
                    int chk = convStm.Read(tobyte, 0, (int)convStm.Length);
                    Buffer.BlockCopy(tobyte, 0, buffWriting, i * tobyte.Length, tobyte.Length);

                    conversionStm.Close();
                    rawSrcStm.Close();
                    bufStm.Close();
                    memStm.Close();

                    convStm.Close();
                    to16.Close();
                    channelStm.Close();
                    mixer.Close();

                    // 삭제
                    lExtension1.Remove(ls1[i]);
                    ls0.Insert(i + 1, ls0[i]);
                }
            }

            // 10개의 버프를 바이트로 만들어 WaveFileWrite
            WaveFileWriting(buffWriting, processingFn);
        }
Exemplo n.º 12
0
 public NAudioDriver(IntPtr WindowHandle)
 {
     Name = "NAudio Driver";
     AssociatedHandle = WindowHandle;
     Mixer = new WaveMixerStream32();
 }
Exemplo n.º 13
0
        /// <summary>
        /// Mescla dois arquivos Mp3, sobrepondo suas faixas.
        /// </summary>                
        public static MemoryStream MesclarMp3(string arquivoTrilhaSonora, float volumeTrilha, string arquivoVoz, float volumeVoz)
        {
            // Lê os arquivos MP3 do disco
            Mp3FileReader mpTrilhaSonora = new Mp3FileReader(arquivoTrilhaSonora);
            Mp3FileReader mpVoz = new Mp3FileReader(arquivoVoz);

            //Decodifica os arquivos MP3
            WaveStream trilhaSonora = WaveFormatConversionStream.CreatePcmStream(mpTrilhaSonora);
            WaveStream voz = WaveFormatConversionStream.CreatePcmStream(mpVoz);

            var mixer = new WaveMixerStream32 { AutoStop = true };

            //var vozOffset = trilhaSonora.TotalTime;
            //var vozOffsetted = new WaveOffsetStream(voz, TimeSpan.FromSeconds(10), TimeSpan.Zero, voz.TotalTime.Subtract(TimeSpan.FromSeconds(30)));

            var trilhaSonora32 = new WaveChannel32(trilhaSonora) { PadWithZeroes = false, Volume = volumeTrilha };
            mixer.AddInputStream(trilhaSonora32);

            var voz32 = new WaveChannel32(voz) { PadWithZeroes = false, Volume = volumeVoz };
            mixer.AddInputStream(voz32);

            var wave32 = new Wave32To16Stream(mixer);
            // Codifica o Wave para MP3
            return ConverterWaveStreamParaMp3Stream(wave32);
        }
Exemplo n.º 14
0
        private void ProcessMixingFinal(RcvData data, int dataSize)
        {
            string processingFn = string.Format("e:\\{0}_{1}_{2}.wav", data.seqnum, data.extension, data.peernumber);

            List<RecInfos> ls0 = lExtension0.FindAll(
                        delegate(RecInfos list)
                        {
                            return list.rcvData.Equals(data) && list.isExtension == 0;
                        });

            List<RecInfos> ls1 = lExtension1.FindAll(
                        delegate(RecInfos list)
                        {
                            return list.rcvData.Equals(data) && list.isExtension == 1;
                        });

            IsExtensionComparer isExtensionCompare = new IsExtensionComparer();
            ls0.Sort(isExtensionCompare);
            ls1.Sort(isExtensionCompare);

            int count = 0;
            int count0 = ls0.Count();
            int count1 = ls1.Count();

            if (count0 - count1 < 0)
                count = count0;
            else
                count = count1;

            for (int i = 0; i < count; i++)
            {
                if (ls0[i].seq == ls1[i].seq)
                {
                    // 믹싱

                    byte[] wavSrc0 = new byte[160];
                    byte[] wavSrc1 = new byte[160];

                    Array.Copy(ls0[i].voice, 12, wavSrc0, 0, wavSrc0.Length);
                    Array.Copy(ls1[i].voice, 12, wavSrc1, 0, wavSrc1.Length);

                    WaveMixerStream32 mixer = new WaveMixerStream32();
                    //mixer.AutoStop = true;

                    WaveChannel32 channelStm = null;

                    for (int j = 0; j < 2; j++)
                    {
                        MemoryStream memStm = null;
                        BufferedStream bufStm = null;
                        RawSourceWaveStream rawSrcStm = null;
                        WaveFormatConversionStream conversionStm = null;

                        if (j == 0)
                            memStm = new MemoryStream(wavSrc0);
                        else
                            memStm = new MemoryStream(wavSrc1);

                        bufStm = new BufferedStream(memStm);
                        rawSrcStm = new RawSourceWaveStream(bufStm, mulawFormat);
                        conversionStm = new WaveFormatConversionStream(pcmFormat, rawSrcStm);

                        channelStm = new WaveChannel32(conversionStm);
                        mixer.AddInputStream(channelStm);
                    }
                    mixer.Position = 0;

                    if (File.Exists(processingFn))
                    {
                        var wavefilestream = new WaveFileReader(processingFn);
                        byte[] wavefilebyte = new byte[(int)wavefilestream.Length];
                        int chk0 = wavefilestream.Read(wavefilebyte, 0, wavefilebyte.Length);

                        Wave32To16Stream to16 = new Wave32To16Stream(mixer);
                        var conversionStm = new WaveFormatConversionStream(pcmFormat, to16);
                        byte[] tobyte = new byte[(int)conversionStm.Length];
                        int chk1 = conversionStm.Read(tobyte, 0, (int)conversionStm.Length);

                        byte[] desByte = new byte[wavefilebyte.Length + tobyte.Length];

                        conversionStm.Close();
                        wavefilestream.Close();

                        Buffer.BlockCopy(wavefilebyte, 0, desByte, 0, wavefilebyte.Length);
                        Buffer.BlockCopy(tobyte, 0, desByte, wavefilebyte.Length, tobyte.Length);

                        using (MemoryStream memStm = new MemoryStream(desByte))
                        using (BufferedStream buffStm = new BufferedStream(memStm))
                        using (RawSourceWaveStream rawSrcStm = new RawSourceWaveStream(buffStm, pcmFormat))
                        {
                            WaveFileWriter.CreateWaveFile(processingFn, rawSrcStm);
                        }
                    }
                    else
                    {
                        var mixedStm = new Wave32To16Stream(mixer);
                        var convStm = new WaveFormatConversionStream(pcmFormat, mixedStm);
                        WaveFileWriter.CreateWaveFile(processingFn, convStm);
                        convStm.Close();
                        mixedStm.Close();
                    }

                    mixer.Close();

                    // 삭제
                    lExtension0.Remove(ls0[i]);
                    lExtension1.Remove(ls1[i]);
                }
                else if (ls0[i].seq - ls1[i].seq < 0)
                {
                    // ls0 만 믹싱
                    // ls0 원본에 byte[] 붙임 > 원본 byte[]를 wavesream 으로 변환 > wave 파일로 저장

                    if (File.Exists(processingFn))
                    {
                        //wavefilestream = new WaveFileReader(processingFn);
                    }
                    else
                    {

                    }

                    // 삭제
                    lExtension0.Remove(ls0[i]);
                    ls1.Insert(i + 1, ls1[i]);
                }
                else if (ls0[i].seq - ls1[i].seq > 0)
                {
                    // ls1 만 믹싱
                    // ls1 원본에 byte[] 붙임 > 원본 byte[]를 wavesream 으로 변환 > wave 파일로 저장

                    if (File.Exists(processingFn))
                    {
                        //wavefilestream = new WaveFileReader(processingFn);
                    }
                    else
                    {

                    }

                    // 삭제
                    lExtension1.Remove(ls1[i]);
                    ls0.Insert(i + 1, ls0[i]);
                }
            }
        }
Exemplo n.º 15
0
 private void MixDiffForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (playbackStatus != PlaybackStatus.Stopped)
     {
         Stop();
     }
     if (wavePlayer != null)
     {
         wavePlayer.Dispose();
         wavePlayer = null;
     }
     if (mixer != null)
     {
         mixer.Dispose();
         mixer = null;
     }
 }
Exemplo n.º 16
0
 private AudioMixer()
 {
     mixer = new WaveMixerStream32 {
         AutoStop = false
     };
     player = new WasapiOut(AudioClientShareMode.Shared, 100);
     player.Init(mixer);
     player.Play();
 }
Exemplo n.º 17
0
        private void InitializeMixer()
        {
            _sineWaveProviders = new List<SineWaveProvider32>();
            _mixer = new WaveMixerStream32();
            _mixer.AutoStop = false; // TODO: Figure out what this does.

            // Initialize the sine wave providers with the frequences of all the possible Pitches
            // Also add them to the mixer.
            foreach (Pitches pitch in (Pitches[])Enum.GetValues(typeof(Pitches)))
            {
                SineWaveProvider32 sineWaveProvider = new SineWaveProvider32();
                sineWaveProvider.SetWaveFormat(16000, 1); // 16kHz mono
                sineWaveProvider.Frequency = pitch.Frequency();
                sineWaveProvider.Amplitude = 0F; // Default volume for each pitch to "off"
                _sineWaveProviders.Add(sineWaveProvider);

                // Supposedly WaveMixerStream32's don't actually handle WaveProviders, only WaveStreams. *shrug*
                _mixer.AddInputStream(new WaveProviderToWaveStream(sineWaveProvider));
            }

            //_pitchUsageCounters = new int[Enum.GetValues(typeof(Pitches)).Length];
        }