Esempio n. 1
0
        public frmMixTest()
        {
            //Setup the Mixer

            mixer          = new WaveMixerStream32();
            mixer.AutoStop = false;
        }
        /// <summary>
        /// Creates a song player for the given song using the NAudio backend.
        /// </summary>
        /// <param name="s">ISong to play.</param>
        internal JammitNAudioSongPlayer(ISong s)
        {
            _waveOut   = new WaveOutEvent();
            _mixer     = new WaveMixerStream32();
            _channels  = new List <WaveChannel32>();
            _chanNames = new List <string>();

            foreach (var t in s.Tracks)
            {
                if (t.ClassName == "JMFileTrack")
                {
                    var stream = s.GetSeekableContentStream($"{t.Id}_jcfx");
                    _channels.Add(new WaveChannel32(new ImaWaveStream(stream)));
                    _chanNames.Add(t.Title);
                }
                else if (t.ClassName == "JMClickTrack")
                {
                    _channels.Add(new WaveChannel32(new ClickTrackStream(s.Beats)));
                    _chanNames.Add(t.Title);
                }
            }

            foreach (var d in _channels)
            {
                _mixer.AddInputStream(d);
                d.Volume = 0.75f;
            }
            _waveOut.PlaybackStopped += (sender, args) => { Position = TimeSpan.Zero; };
            _waveOut.DesiredLatency   = 60;
            _waveOut.NumberOfBuffers  = 2;
            _waveOut.Init(_mixer);
        }
Esempio n. 3
0
        private void MixTwoSamples()
        {
            while (writer == null && RecordedAudioWriter == null)
            {
            }

            Thread.Sleep(1000);

            MicFileReader     = new AudioFileReader(saveDirectory.SelectedPath + "\\" + micRecordFIleName);
            SpeakerFileReader = new AudioFileReader(saveDirectory.SelectedPath + "\\" + playBackRecordFileName);

            WaveMixerStream32 mixer = new WaveMixerStream32();

            mixer.AddInputStream(MicFileReader);
            mixer.AddInputStream(SpeakerFileReader);

            WaveFileWriter.CreateWaveFile(saveDirectory.SelectedPath + "\\" + "result.wav", mixer);

            MicFileReader.Close();
            MicFileReader.Dispose();
            MicFileReader = null;

            SpeakerFileReader.Close();
            SpeakerFileReader.Dispose();
            SpeakerFileReader = null;
        }
Esempio n. 4
0
        public NAudioJcfPlayer(JcfMedia media)
        {
            _media    = media;
            _waveOut  = new WaveOutEvent();
            _mixer    = new WaveMixerStream32();
            _channels = new Dictionary <TrackInfo, WaveChannel32>(media.InstrumentTracks.Count + 1 + 1);

            var songPath = Path.Combine(Jam.NET.Properties.Settings.Default.TrackPath, $"{media.Song.Id}.jcf");

            foreach (var track in media.InstrumentTracks)
            {
                var stream = File.OpenRead(Path.Combine(songPath, $"{track.Identifier}_jcfx"));
                _channels[track] = new WaveChannel32(new ImaWaveStream(stream));
            }

            var backingStream = File.OpenRead(Path.Combine(Jam.NET.Properties.Settings.Default.TrackPath, $"{media.Song.Id}.jcf"));

            _channels[media.BackingTrack] = new WaveChannel32(new ImaWaveStream(backingStream));

            _channels[media.ClickTrack] = new WaveChannel32(new ClickTrackStream(media.Beats));

            foreach (var channel in _channels.Values)
            {
                _mixer.AddInputStream(channel);
                channel.Volume = 0.75f;//TODO: bind?
            }

            _waveOut.PlaybackStopped += (sender, args) => { Position = TimeSpan.Zero; };
            _waveOut.DesiredLatency   = 60;//TODO: Why?
            _waveOut.NumberOfBuffers  = 2;
            _waveOut.Init(_mixer);
        }
Esempio n. 5
0
        public void MixAudio(Dictionary <String, int[]> songsXtimes)
        {
            lastFile = targetFile += "_" + DateTime.Now.ToString();
            toMix    = new List <WaveFileReader>();
            WaveMixerStream32 combined = null;

            foreach (String s in songsXtimes.Keys)
            {
                PrepareClip(s, songsXtimes[s]);
                //chop it up and add it to toMix
            }
            combined = Combine();


            Wave32To16Stream wavmixer = new Wave32To16Stream(combined);

            WaveFileWriter.CreateWaveFile(targetFile, wavmixer);
            wavmixer.Dispose();
            combined.Dispose();

            /*
             * byte[] b = new byte[combined.Length];
             * int len = (int)combined.Length;
             * combined.Read(b,0,len);
             * combined.Close();
             * WaveFileWriter wv = new WaveFileWriter(targetFile, combined.WaveFormat);
             * wv.Write(b, 0, (int)combined.Length);
             * */
            return;
        }
Esempio n. 6
0
        //Jam.NET.Properties.Settings.Default.TrackPath
        public NAudioJcfPlayer(JcfMedia media, IWavePlayer waveOut, string tracksPath, byte[] stick)
        {
            _media    = media;
            _waveOut  = waveOut;
            _mixer    = new WaveMixerStream32();
            _channels = new Dictionary <TrackInfo, WaveChannel32>(media.InstrumentTracks.Count + 1 + 1);

            var songPath = Path.Combine(tracksPath, $"{media.Song.Sku}.jcf");

            foreach (var track in media.InstrumentTracks)
            {
                var stream = File.OpenRead(Path.Combine(songPath, $"{track.Identifier.ToString().ToUpper()}_jcfx"));
                _channels[track] = new WaveChannel32(new ImaWaveStream(stream));
            }

            var backingStream = File.OpenRead(Path.Combine(songPath, $"{media.BackingTrack.Identifier.ToString().ToUpper()}_jcfx"));

            _channels[media.BackingTrack] = new WaveChannel32(new ImaWaveStream(backingStream));
            _channels[media.ClickTrack]   = new WaveChannel32(new ClickTrackStream(media.Beats, stick));

            foreach (var channel in _channels.Values)
            {
                _mixer.AddInputStream(channel);
                channel.Volume = 1.00f;//TODO: bind?
            }

            _waveOut.PlaybackStopped += (sender, args) => { Position = TimeSpan.Zero; };
            //_waveOut.DesiredLatency = 60;//TODO: Why?
            //_waveOut.NumberOfBuffers = 2;
            _waveOut.Init(_mixer);
        }
Esempio n. 7
0
 public ScoreMusicPlayer()
 {
     _syncObject  = new object();
     _waveStream  = new WaveMixerStream32();
     _soundPlayer = new AudioOut();
     _soundPlayer.Init(_waveStream);
     _channels = new Dictionary <WaveStream, WaveChannel32>();
 }
Esempio n. 8
0
 public ScorePlayer()
 {
     _syncObject  = new object();
     _waveStream  = new WaveMixerStream32();
     _soundPlayer = new AudioOut(AudioClientShareMode.Shared, 60);
     _soundPlayer.Init(_waveStream);
     _channels = new Dictionary <WaveStream, WaveChannel32>();
     PlayerSettings.MusicVolumeChanged += OnMusicVolumeChanged;
 }
Esempio n. 9
0
 public void Init(string path)
 {
     sinfo  = new StreamInfo(path);
     _mixer = new WaveMixerStream32();
     _mixer.AddInputStream(sinfo.Stream);
     _wavePlayer = new WaveOut();
     _wavePlayer.Init(_mixer);
     _mixer.AutoStop = false;
     _skipSeconds    = 3;
     Status          = PlaybackStatus.Stopped;
 }
Esempio n. 10
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);
 }
Esempio n. 11
0
        private void addMixerStream(WaveMixerStream32 mixer, string fileName)
        {
            // create a wave stream and a channel object
            var reader  = new WaveFileReader(fileName);
            var channel = new WaveChannel32(reader)
            {
                //Set the volume
                Volume = 1.0f
            };

            mixer.AddInputStream(channel);
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
        private void convertToMp3()
        {
            if (IsRecording)
            {
                return;
            }

            int i          = 0;
            var outputFile = Path.Combine(SettingsFile.Instance.SavePath, buildFileName(i));

            while (File.Exists(outputFile))
            {
                outputFile = Path.Combine(SettingsFile.Instance.SavePath, buildFileName(++i));
            }

            try {
                log.Debug($"Generating mp3: {outputFile}");

                var tag = new ID3TagData();
                tag.UserDefinedText.Add("CallId", Call.CallId);
                tag.UserDefinedText.Add("From", Call.From?.SkypeId);
                tag.UserDefinedText.Add("FromDisplayName", Call.From?.DisplayName);
                tag.UserDefinedText.Add("To", Call.To?.SkypeId);
                tag.UserDefinedText.Add("ToDisplayName", Call.To?.DisplayName);

                var mixer = new WaveMixerStream32 {
                    AutoStop = true
                };

                log.Debug($"  adding wave input: {_micSourceFile}");
                addMixerStream(mixer, _micSourceFile);
                log.Debug($"  adding wave input: {_spkSourceFile}");
                addMixerStream(mixer, _spkSourceFile);

                log.Debug($"  encoding");
                var wave32    = new Wave32To16Stream(mixer);
                var mp3Writer = new LameMP3FileWriter(outputFile, wave32.WaveFormat, LAMEPreset.VBR_90, tag);
                wave32.CopyTo(mp3Writer);

                // close all streams
                wave32.Close();
                mp3Writer.Close();

                log.Debug($"  finished, removing temp files");

                File.Delete(_micSourceFile);
                File.Delete(_spkSourceFile);
            }
            catch (Exception ex) {
                log.Error("Error generating mp3: " + ex.Message, ex);
            }
        }
Esempio n. 14
0
        public AudioManager()
        {
            _mixerStream = new WaveMixerStream32 {
                AutoStop = false
            };

            _soundPlayer = new AudioOut(AudioClientShareMode.Shared, 60);
            _soundPlayer.Init(_mixerStream);

            Sfx = new SfxManager(this);

            _soundPlayer.Play();
        }
Esempio n. 15
0
 public void Dispose()
 {
     try
     {
         _wavePlayer.Dispose();
         _mixer.Dispose();
         _wavePlayer = null;
         _mixer      = null;
     }
     catch (Exception e)
     {
         Handle(e);
     }
 }
Esempio n. 16
0
        public WaveMixerStream32 Combine()
        {
            WaveMixerStream32 wavMix = new WaveMixerStream32();

            wavMix.AutoStop = true;

            foreach (WaveFileReader reader in toMix)
            {
                WaveChannel32 wc3 = new WaveChannel32(reader);
                wavMix.AddInputStream(wc3);
            }

            wavMix.Position = 0;
            return(wavMix);
        }
        public void Export(Pattern pattern, int bpm, string outputPath, int sampleRate, int bitsPerSample, int channels)
        {
            using (var streamTracker = new StreamTracker())
            {
                var finalMixer = new WaveMixerStream32();
                streamTracker.AddStream(finalMixer);

                AddInstrumentStreamsToMixer(pattern, bpm, finalMixer, streamTracker);

                WaveStream finalStream = ConvertTo(finalMixer, sampleRate, bitsPerSample, channels);
                streamTracker.AddStream(finalStream);

                WaveFileWriter.CreateWaveFile(outputPath, finalStream);
            }
        }
Esempio n. 18
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;
     }
 }
Esempio n. 19
0
    public static void MixWavFiles(string[] inputFiles, string outFileName)
    {
        int count = inputFiles.GetLength(0);
        WaveMixerStream32 mixer = new WaveMixerStream32();

        WaveFileReader[] reader       = new WaveFileReader[count];
        WaveChannel32[]  channelSteam = new WaveChannel32[count];
        mixer.AutoStop = true;

        for (int i = 0; i < count; i++)
        {
            reader[i]       = new WaveFileReader(inputFiles[i]);
            channelSteam[i] = new WaveChannel32(reader[i]);
            mixer.AddInputStream(channelSteam[i]);
        }
        mixer.Position = 0;
        WaveFileWriter.CreateWaveFile(outFileName, mixer);
    }
        public void SetData(ref byte[] path, ref byte[] pathToBack, int rate, int bits, int channel)
        {
            WaveFormat waveFormat = new WaveFormat(rate, bits, channel);

            Stop();

            StopAndCloseStream();

            try
            {
                WaveOut outDevice = new WaveOut {
                    DesiredLatency = 500
                };                                                          //100
                waveOutDevice = outDevice;
                byte[] waveData = null;
                SetWaveHeader(ref path, waveFormat, out waveData);

                byte[] backWaveData = null;
                SetWaveHeader(ref pathToBack, waveFormat, out backWaveData);

                List <WaveStream> waveProviders = new List <WaveStream>();

                waveProviders.Add(new WaveChannel32(new RawSourceWaveStream(new MemoryStream(waveData), waveFormat)));
                waveProviders.Add(new WaveChannel32(new RawSourceWaveStream(new MemoryStream(backWaveData), waveFormat)));

                ActiveStream = new WaveMixerStream32(waveProviders, false);

                _streamToPlay         = new WaveChannel32(ActiveStream);
                _streamToPlay.Sample += ForwardStreamSample;
                waveOutDevice.Init(_streamToPlay);

                ChannelLength = _streamToPlay.TotalTime.TotalSeconds;

                GenerateWaveformData(waveData, backWaveData, waveFormat);
                CanPlay = true;
            }
            catch
            {
                ActiveStream = null;
                CanPlay      = false;
            }
        }
Esempio n. 21
0
        public WaveStream GetMetronome(int tempo, int bars, Stream bufferStream)
        {
            Mp3FileReader stick  = new Mp3FileReader(@"sounds\stick.mp3");
            Mp3FileReader stick2 = new Mp3FileReader(@"sounds\stick.mp3");

            //Wave
            WaveStream stickWave  = WaveFormatConversionStream.CreatePcmStream(stick);
            WaveStream stick2Wave = WaveFormatConversionStream.CreatePcmStream(stick2);

            var stick32 = new WaveChannel32(stickWave);

            stick32.PadWithZeroes = false;
            stick32.Volume        = 1.0f;

            double seconds = 60f / tempo;

            var stickOff = new WaveOffsetStream(stick2Wave, TimeSpan.FromSeconds(seconds), TimeSpan.Zero,
                                                stick2Wave.TotalTime);
            var stickOff32 = new WaveChannel32(stickOff);

            stickOff32.PadWithZeroes = false;
            stickOff32.Volume        = 1.0f;

            // Add to the mixer.
            var mixer = new WaveMixerStream32();

            mixer.AutoStop = true;
            mixer.AddInputStream(stick32);
            mixer.AddInputStream(stickOff32);

            var outputWav = new Wave32To16Stream(mixer);

            using (MemoryStream mem = new MemoryStream())
            {
                WaveStream trimmed = TrimWaveStream(outputWav, TimeSpan.Zero,
                                                    outputWav.TotalTime.Subtract(TimeSpan.FromSeconds(seconds * 2)), mem);

                var looped = LoopStream(trimmed, bars * 2, bufferStream);
                return(looped);
            }
        }
Esempio n. 22
0
        public static WaveStream Mix(this WaveStream stream, WaveStream stream2)
        {
            var mixer = new WaveMixerStream32();

            mixer.AutoStop = true;

            var chann1 = new WaveChannel32(stream);

            chann1.PadWithZeroes = false;
            chann1.Volume        = 1.0f;

            var chann2 = new WaveChannel32(stream2);

            chann2.PadWithZeroes = false;
            chann2.Volume        = 1.0f;

            mixer.AddInputStream(chann1);
            mixer.AddInputStream(chann2);

            return(mixer);
        }
Esempio n. 23
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));
        }
Esempio n. 24
0
        private static void mainOutput_PlaybackStopped(object sender, EventArgs e)
        {
            try
            {
                mainOutput.Stop();

                mainOutput.Dispose();
                mixerin.Dispose();
                mixerin.Close();
                mainOutput = null;
                mixerin    = null;


                Thread.Sleep(400);

                onLoop();
            }
            catch (Exception erri)
            {
                onError(erri.Message);
            }
        }
Esempio n. 25
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
            }
        }
        private static void EnsureLength(Pattern pattern, int msPerBeat, WaveMixerStream32 finalMixer, StreamTracker streamTracker)
        {
            int avgBytesPerMs = finalMixer.WaveFormat.AverageBytesPerSecond / 1000;
            int beatArrayLen  = avgBytesPerMs * msPerBeat;
            var silence       = new byte[beatArrayLen];
            var mem           = new IgnoreDisposeStream(new MemoryStream());

            streamTracker.AddStream(mem);

            using (var writer = new WaveFileWriter(mem, finalMixer.WaveFormat))
            {
                for (int i = 0; i < pattern.NumberOfBeats; ++i)
                {
                    writer.Write(silence, 0, silence.Length);
                    writer.Flush();
                }
            }

            mem.Position = 0;

            var rdr = new WaveFileReader(mem);

            finalMixer.AddInputStream(rdr);
        }
Esempio n. 27
0
 public static string Converter(string inPath)
 {
     using (WaveFileReader mpbacground = new WaveFileReader(inPath))
     {
         using (WaveStream background = WaveFormatConversionStream.CreatePcmStream(mpbacground))
         {
             using (var mixer = new WaveMixerStream32())
             {
                 mixer.AutoStop = true;
                 var messageOffset = background.TotalTime;
                 var background32  = new WaveChannel32(background);
                 background32.PadWithZeroes = false;
                 mixer.AddInputStream(background32);
                 using (var wave32 = new Wave32To16Stream(mixer))
                 {
                     var mp3Stream = ConvertWavToMp3(wave32);
                     inPath = inPath.Split('.')[0] + ".mp3";
                     File.WriteAllBytes(inPath, mp3Stream.ToArray());
                 }
             }
         }
     }
     return(inPath);
 }
        public void graj()
        {
            WaveMixerStream32 mixer = new WaveMixerStream32 {
                AutoStop = false,
            };

            IWavePlayer     waveOutDevice;
            AudioFileReader audioFileReader;

            //waveOutDevice = new WaveOut();
            waveOutDevice = new WaveOut(WaveCallbackInfo.NewWindow());



            //if (stop_but.Checked) break;

            //Thread thread2 = new Thread(graj);
            //thread2.Start();
            for (int i = 0; i <= 15; i++)//foreach nie zdał tu egzaminu, puszczał dzwiek dwa razy
            {
                if (stop == 1)
                {
                    break;
                }
                if (tab[i] == 0)
                {
                    //while(i<=15)
                    //ilosc_sampli = 1;
                    Thread.Sleep(ms);
                    //if (i <= 14) progress++;
                    //if (i == 15) progress = 0;
                }
                if (tab[i] == 1)
                {
                    //ilosc_sampli = 1;

                    //if (i <= 14) progress++;
                    // if (i == 15) progress = 0;

                    {
                        // DeviceNumber = 1,
                        // DesiredLatency = 300,
                        // NumberOfBuffers = 3,
                    };
                    // waveOutDevice.Init(mixer);
                    try
                    {
                        AudioFileReader afr = new AudioFileReader(sampel);
                        waveOutDevice.Init(afr);
                        waveOutDevice.Play();


                        //int le = waveOutDevice.Play.;
                        //if (waveOutDevice.PlaybackState == PlaybackState.Playing)
                        //{
                        //while (i <= 15)
                        Thread.Sleep(ms);
                    }
                    catch
                    {
                        if (string.IsNullOrEmpty(sampel))
                        {
                            MessageBox.Show("wygląda na to, że zapomniałeś gdzieś wybrać jaki dźwiek mam grać :) wybierz sample klikając przyciski obok siatki, a następnie kliknij stop  ");
                            break;
                        }
                        //else continue;
                    }
                    //if (progressBar1.Value == 15) progressBar1.Value = 0;
                }
            }
        }
Esempio n. 29
0
        public void Play(string soundName)
        {
            try
            {
                if (aguante >= 30)
                {
                    return;
                }

                //aguante++;
                //if (output[direccion[soundName]].PlaybackState == PlaybackState.Playing)
                // {
                if (soundName.EndsWith(".wav") == true)
                {
                    //playWithMedia(soundName);
                    //return;
                }
                ISound sfx = controlador.Play2D(soundName);
                sfx.Dispose();

                return;


                WaveStream        auxoxo = CreateInputStreamReturnable(soundName);
                WaveMixerStream32 extrr  = new WaveMixerStream32();
                extrr.AutoStop = true;
                extrr.AddInputStream(auxoxo);

                auxoxo.Position = 0;


                DirectSoundOut auxili = new DirectSoundOut();


                diccionarioLoco.Add(auxili, auxoxo);
                diccionarioReLocoMixer.Add(auxili, extrr);

                auxili.PlaybackStopped += new EventHandler(auxili_PlaybackStopped);


                auxili.Init(extrr);
                auxili.Play();


                /*auxili.Dispose();
                 *  auxili.Stop();
                 *
                 *
                 *  //error("dentro del if");
                 *
                 * //}
                 * else
                 * {
                 *  mainStreams[direccion[soundName]].Position = 0;
                 *  mixeador[direccion[soundName]].AddInputStream(mainStreams[direccion[soundName]]);
                 *
                 *  output[direccion[soundName]].Init(mixeador[direccion[soundName]]);
                 *
                 *  output[direccion[soundName]].Play();
                 *
                 *
                 *  output[direccion[soundName]].Init(mainStreams[direccion[soundName]]);
                 *  output[direccion[soundName]].Play();
                 *
                 *  output[direccion[soundName]].Dispose();
                 *
                 *
                 *  error("no estoy en el if ");
                 *
                 * }
                 *
                 * output[direccion[soundName]].PlaybackStopped += new EventHandler(MainPlayer_PlaybackStopped);
                 *
                 */
            }
            catch (Exception e)
            {
                if (error != null)
                {
                    error(e.Message + " error en play " + direccion[soundName]);
                }
            }
        }
Esempio n. 30
0
 public MockSongPlayer(ISong s)
 {
     _mixer = new WaveMixerStream32();
     _mixer.AddInputStream(new WaveChannel32(new Jammit.Audio.ClickTrackStream(s.Beats, Properties.Resources.stick)));
 }