Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {/*Array.Sort();*/
            OpenFileDialog OPPOEpe = new OpenFileDialog();

            OPPOEpe.Filter = "Wawe file (*.mp3|*mp3;) ";
            if (OPPOEpe.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            DisposeWave();
            NAudio.Wave.WaveStream p = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(OPPOEpe.FileName));
            button1.Text = p.WaveFormat.ToString();

            stream = new NAudio.Wave.BlockAlignReductionStream(p);

            TimeSpan error = new TimeSpan(0, 0, 0);

            TimeSpan error1 = new TimeSpan(0, 0, 1);
            TimeSpan error2 = new TimeSpan(1, 0, 1);

            NAudio.Wave.WaveOffsetStream str = new NAudio.Wave.WaveOffsetStream(stream, error, error1, error2);
            gavnout = new NAudio.Wave.DirectSoundOut();
            str.Skip(100);

            gavnout.Init(str);

            gavnout.Play();
        }
Example #2
0
 private void gg(string name)
 {
     NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(@"C:\Program Files (x86)\Mektep\sound\" + name));
     stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
     output = new NAudio.Wave.DirectSoundOut();
     output.Init(stream);
 }
        //allows the user to playback recorded .wav files or use it as a media player
        private void openFileBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "Wave File (*.wav)|*.wav;";
            if (open.ShowDialog() != DialogResult.OK) return;
            filePathLbl.Text = open.FileName;
            DisposeWave(); //clears the wavefilereader of any previous contents and disposes of the waveout device

            // sets the wavefile reader and waveout up afresh using the contents of the newly selected file
            wFileReader = new NAudio.Wave.WaveFileReader(open.FileName); 
            waveOut = new NAudio.Wave.DirectSoundOut();
            waveOut.Init(new NAudio.Wave.WaveChannel32(wFileReader));

            //The rest of this method was an attempt at creating a waveViewer object in the large open white space using a graph
            // to plot the points of each sample.

            //NAudio.Wave.WaveChannel32 wave = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));
            //automatically converts format to get 32bit floating point number of wave file

            //converts from byte array to a floating pint number
            //byte[] buffer = new byte[16384]; //read 16kb at a time from wav file
            //int read = 0; //number of bytes read

            //while (wave.Position < wave.Length) //do until end of wave file
            //{
            //    read = wave.Read(buffer, 0, 16384); //reading from byte buffer, from beginning, read all bytes in buffer
            //    for (int i = 0; i < read / 4; i++) // 4 bytes per floating point number
            //    {
            //     //   waveViewChart.Series["wave"].Points.Add(BitConverter.ToSingle(buffer, i * 4)); 
            //        //add point to chart from converted bit to 32bit floating point number
            //        //uses the buffer as byte array and 1 * 4 as the index point from buffer in which to read
            //    }
            //}
        }
Example #4
0
        /// <summary>
        /// Plays sound from start
        /// </summary>
        public void PlaySound()
        {
            if (fileName.EndsWith(".mp3"))
            {
                NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(fileName));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            }
            else if (fileName.EndsWith(".wav"))
            {
                NAudio.Wave.WaveStream pcm = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(fileName));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            }
            else
            {
                throw new InvalidOperationException("Not a correct audio file type. Supports mp3 and wav only!");
            }

            if (output == null)
            {
                output = new NAudio.Wave.DirectSoundOut();
            }

            output.Init(stream);
            output.Play();
        }
Example #5
0
 private void Musice2()
 {
     Chaikovsky = new NAudio.Wave.WaveFileReader("BOOM.wav");
     Borodin    = new NAudio.Wave.DirectSoundOut();
     Borodin.Init(new NAudio.Wave.WaveChannel32(Chaikovsky));
     Borodin.Play();
 }
Example #6
0
        //druga himna
        void output_PlaybackStopped(object sender, NAudio.Wave.StoppedEventArgs e)
        {
            if (notClosed)
            {
                try
                {
                    DisposeWave();

                    byte[]                 gostPesma  = AuxLib.LoadSoundFromGridFS(gost.Ime + "himna");
                    MemoryStream           gostStream = new MemoryStream(gostPesma);
                    NAudio.Wave.WaveStream pcm        = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(gostStream));
                    stream = new NAudio.Wave.BlockAlignReductionStream(pcm);


                    output = new NAudio.Wave.DirectSoundOut();
                    output.Init(stream);

                    output.Play();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
        }
Example #7
0
        // function to check a valid hit in the program
        private void CheckForAHit()
        {
            Image <Gray, byte> temp;

            for (int i = 0; i < NumberOfBalls; i++)
            {
                temp = Balls[i].And(DifferenceFrame);
                temp = temp.ThresholdBinary(new Gray(240), new Gray(255));
                int number = temp.CountNonzero()[0];

                if (number != 0)
                {
                    MCvFont font      = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_DUPLEX, 1d, 1d);
                    MCvFont fontSmall = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_TRIPLEX, .25d, .5d);
                    NumberOfHits++;
                    Score++;
                    bomb = new NAudio.Wave.WaveFileReader(Constants.BOMB_EXPLOSION_FILE_LOC);

                    //TODO: move the initlization out and make sure that only once the init happens
                    output = new NAudio.Wave.DirectSoundOut();
                    output.Init(new NAudio.Wave.WaveChannel32(bomb));
                    Random r = new Random();
                    InputImageFrame.Draw(new CircleF(new PointF(XYCoordinatesOfBalls[i, 0], XYCoordinatesOfBalls[i, 1]), 10), new Bgr(r.Next(0, 255), 0, 255), 50);

                    InputImageFrame.Draw("Hit", ref font, new Point(XYCoordinatesOfBalls[i, 0] - 20, XYCoordinatesOfBalls[i, 1] + 10), new Bgr(Color.White));
                    generateXYCoordiantesForBall(i);
                }
            }
            if (output != null)
            {
                output.Play();
            }
        }
        private void openFileButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "Audio File (*.mp3;*.wav)|*.mp3;*.wav;";
            if (open.ShowDialog() != DialogResult.OK) return;

            DisposeWave();

            if (open.FileName.EndsWith(".mp3"))
            {
                NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(open.FileName));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            }
            else if (open.FileName.EndsWith(".wav"))
            {
                NAudio.Wave.WaveStream pcm = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            }
            else throw new InvalidOperationException("Not a correct audio file type.");

            output = new NAudio.Wave.DirectSoundOut();
            output.Init(stream);
            output.Play();

            pauseButton.Enabled = true;
        }
Example #9
0
        private void button10_Click(object sender, EventArgs e)
        {
            var client   = new MongoClient("mongodb://localhost");
            var database = client.GetDatabase("docs");
            var fs       = new GridFSBucket(database);

            //var aaa = fs.Find()
            var test = fs.DownloadAsBytesByName("Muzika");

            MemoryStream memStream = new MemoryStream(test);

            //OpenFileDialog open = new OpenFileDialog();
            //open.Filter = "Audio File (*.mp3;*.wav)|*.mp3;*.wav;";
            //if (open.ShowDialog() != DialogResult.OK) return;

            DisposeWave();

            // if (open.FileName.EndsWith(".mp3"))
            // {
            NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(memStream));
            stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            // }
            // else if (open.FileName.EndsWith(".wav"))
            //{
            //    NAudio.Wave.WaveStream pcm = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));
            //    stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            //}
            //else throw new InvalidOperationException("Not a correct audio file type.");

            output = new NAudio.Wave.DirectSoundOut();
            output.Init(stream);
            output.Play();
        }
Example #10
0
        private void bt_Abrir_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();

            open.Filter = "Audio File (*.mp3;*.wav)|*.mp3;*.wav;";
            if (open.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            DisposeWave();

            if (open.FileName.EndsWith(".mp3"))
            {
                NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(open.FileName));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            }
            else if (open.FileName.EndsWith(".wav"))
            {
                NAudio.Wave.WaveStream pcm = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            }
            else
            {
                throw new InvalidOperationException("Not a correct audio file type.");
            }

            output = new NAudio.Wave.DirectSoundOut();
            output.Init(stream);
            output.Play();

            bt_Play_Stop.Enabled = true;
        }
Example #11
0
 private void pictureBox3_Click(object sender, EventArgs e)
 {
     DisposeAll();
     wave   = new NAudio.Wave.WaveFileReader(Path);
     player = new NAudio.Wave.DirectSoundOut();
     player.Init(new NAudio.Wave.WaveChannel32(wave));
     player.Play();
 }
Example #12
0
        private void jollyPicBox_Click(object sender, EventArgs e)
        {
            string file = "Class" + LoginForm.classSec + "_kidAudio/" + lvlStr.ToLower() + ".wav";

            DisposeWave();

            wave   = new NAudio.Wave.WaveFileReader(file);
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(new NAudio.Wave.WaveChannel32(wave));
            output.Play();
        }
Example #13
0
        private void jollyPicBox_Click_1(object sender, EventArgs e)
        {
            string file = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\TeacherWAV\" + lvlStr.ToLower() + ".wav";

            DisposeWave();

            wave   = new NAudio.Wave.WaveFileReader(file);
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(new NAudio.Wave.WaveChannel32(wave));
            output.Play();
        }
Example #14
0
        //Plays/Repeats the audio of the letter
        private void repeatBtn_Click(object sender, EventArgs e)
        {
            String filename = "Class" + LoginForm.classSec + "_kidAudio/" + letters[curPos] + ".wav";

            DisposeWave();

            wave   = new NAudio.Wave.WaveFileReader(filename);
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(new NAudio.Wave.WaveChannel32(wave));
            output.Play();
        }
Example #15
0
        private void GoalSoundPlay()
        {
            goalSound.Position = 0;
            NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(goalSound));
            stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(stream);
            output.Play();

            Thread.Sleep(3000);
            this.DisposeWave();
        }
Example #16
0
        //Used to play out what is recording
        private void button2_Click(object sender, EventArgs e)
        {
            sourcestream.DeviceNumber = 0;
            int deviceNumber = SourceList.SelectedItems[0].Index;

            sourcestream            = new NAudio.Wave.WaveIn();
            sourcestream.WaveFormat = new NAudio.Wave.WaveFormat(44100, NAudio.Wave.WaveIn.GetCapabilities(0).Channels);
            NAudio.Wave.WaveInProvider waveIn = new NAudio.Wave.WaveInProvider(sourcestream);
            wavout = new NAudio.Wave.DirectSoundOut();
            wavout.Init(waveIn);
            sourcestream.StartRecording();
            wavout.Play();
        }
        private void GoalSoundPlay()
        {
            goalSound.Position = 0;
            NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(goalSound));
            stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(stream);
            output.Play();

            Thread.Sleep(3000);
            this.DisposeWave();
                                    
        }
Example #18
0
        private void onKeyDown(object sender, KeyEventArgs e)
        {
            if (modActive == true)
            {
                // Sheathe / Unsheathe
                if (e.KeyCode == sheathe && !keyUp && !Game.Player.Character.IsSittingInVehicle())
                {
                    keyUp = true;

                    if (!spear.IsAttachedTo(Game.Player.Character))
                    {
                        spearActive = false;
                    }
                    else
                    {
                        spearActive = !spearActive;
                    }

                    // Sheathe
                    if (!spearActive)
                    {
                        spear.Detach();
                        unsheathed = false;

                        NAudio.Wave.WaveFileReader mp3whis1 = new NAudio.Wave.WaveFileReader(@"scripts\Spear Files\unsheathe.wav");
                        NAudio.Wave.WaveChannel32  waveDown = new NAudio.Wave.WaveChannel32(mp3whis1);
                        NAudio.Wave.DirectSoundOut output   = new NAudio.Wave.DirectSoundOut();
                        output.Init(waveDown);
                        output.Play();
                        waveDown.Volume = 0.05f;
                    }
                    else if (spear.IsAttachedTo(Game.Player.Character))
                    {
                        // Unsheathe
                        spear.AttachTo(Game.Player.Character, Game.Player.Character.GetBoneIndex(Bone.SKEL_Head),
                                       new Vector3(0.2f, 1, -0.2f),
                                       new Vector3(90, 0, 0)
                                       );

                        unsheathed = true;

                        NAudio.Wave.WaveFileReader recall  = new NAudio.Wave.WaveFileReader(@"scripts\Spear Files\return.wav");
                        NAudio.Wave.WaveChannel32  waveRec = new NAudio.Wave.WaveChannel32(recall);
                        NAudio.Wave.DirectSoundOut output3 = new NAudio.Wave.DirectSoundOut();
                        output3.Init(waveRec);
                        output3.Play();
                        waveRec.Volume = 0.05f;
                    }
                }
            }
        }
Example #19
0
 private void Play_Click(object sender, EventArgs e)
 {
     try
     {
         NAudio.Wave.IWaveProvider provider = new NAudio.Wave.RawSourceWaveStream(new System.IO.MemoryStream(ms.ToArray()), new NAudio.Wave.WaveFormat(sampleRate, 16, 2));
         waveOut = new NAudio.Wave.DirectSoundOut();
         waveOut.Init(provider);
         waveOut.Play();
     }
     catch
     {
         MessageBox.Show("Please Record Before Playing", "Missing Audio", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #20
0
        public Main()
        {
            InitializeComponent();
            AMFParser.Initialize();

            /////////////////////////////////////////////////////////////////////////
            /// Setting up automatic audio playback (NAudio)
            MemoryStream mp3file = new MemoryStream(Properties.Resources.ECLiPSE_CyberMotion);

            NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(mp3file));
            NAudio.Wave.BlockAlignReductionStream stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            NAudio.Wave.DirectSoundOut            output = new NAudio.Wave.DirectSoundOut(700); //audio latency (to stop crackling)
            output.PlaybackStopped += (pbss, pbse) => { System.Threading.Thread.Sleep(1000); stream.Position = 0; output.Play(); };
            output.Init(stream);
            output.Play();
            /////////////////////////////////////////////////////////////////////////

            //users.dat holds captured usernames and uuids locally
            //format: username > xxxxx-xxxx-xxx...(36 character uuid)

            if (!File.Exists("users.dat"))
            {
                File.Create("users.dat").Close();
            }

            foreach (string line in File.ReadAllLines("users.dat"))
            {
                uuid_combobox.Items.Add(line);
            }

            if (uuid_combobox.Items.Count > 0)
            {
                uuid_combobox.SelectedIndex = 0;
            }

            //gets and lists all available network interfaces
            NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface nic in nics)
            {
                if (nic.OperationalStatus == OperationalStatus.Up)
                {
                    adapter_combobox.Items.Add(String.Format("{0}: {1}", nic.Name, nic.Id));
                }
            }

            if (adapter_combobox.Items.Count > 0)
            {
                adapter_combobox.SelectedIndex = 0;
            }
        }
Example #21
0
        public void RecordAndPlay()
        {
            m_oSourceStream = new NAudio.Wave.WaveIn();
            m_oSourceStream.DeviceNumber = m_iDeviceNumber;
            m_oSourceStream.WaveFormat   = new NAudio.Wave.WaveFormat(44100, NAudio.Wave.WaveIn.GetCapabilities(m_iDeviceNumber).Channels);

            NAudio.Wave.WaveInProvider oWaveIn = new NAudio.Wave.WaveInProvider(m_oSourceStream);

            m_oWaveOut = new NAudio.Wave.DirectSoundOut();
            m_oWaveOut.Init(oWaveIn);

            m_oSourceStream.StartRecording();
            m_oWaveOut.Play();
        }
Example #22
0
        private void Form11_Load_1(object sender, EventArgs e)
        {
            //AllocConsole();
            buttonMute.Parent = this;

            buttonPlay.Parent = this;
            wave   = new NAudio.Wave.WaveFileReader("lofi.wav");
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(new NAudio.Wave.WaveChannel32(wave));
            output.Play();

            buttonMute.Enabled = true;
            buttonPlay.Visible = false;
            buttonMute.Visible = true;
        }
Example #23
0
        private void button9_Click(object sender, EventArgs e)
        {
            FileStream     Tstream;
            OpenFileDialog ofd      = new OpenFileDialog();
            var            client   = new MongoClient("mongodb://localhost");
            var            database = client.GetDatabase("docs");
            var            fs       = new GridFSBucket(database);

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Tstream = new System.IO.FileStream(ofd.FileName, FileMode.Open, FileAccess.Read);
                //SoundPlayer simpleSound = new SoundPlayer(stream);
                //simpleSound.Play();
                var split = ofd.SafeFileName.Split('.');
                if (split[1] != "mp3")
                {
                    MessageBox.Show("Izaberite mp3 fajl!");
                    return;
                }
                DisposeWave();

                NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(Tstream));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
                // }
                // else if (open.FileName.EndsWith(".wav"))
                //{
                //    NAudio.Wave.WaveStream pcm = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));
                //    stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
                //}
                //else throw new InvalidOperationException("Not a correct audio file type.");

                output = new NAudio.Wave.DirectSoundOut();
                output.Init(stream);
                output.Play();

                //GridFSUploadOptions opcije = new GridFSUploadOptions();
                //opcije.ContentType = "audio/mp3";
                //opcije.ChunkSizeBytes = Convert.ToInt32(stream.Length)/4;

                //int duzina = Convert.ToInt32(stream.Length);
                //byte[] bajtovi = new byte[duzina];
                //stream.Seek(0, SeekOrigin.Begin);
                //int bytesRead = stream.Read(bajtovi, 0, duzina);

                //fs.UploadFromBytes(ofd.SafeFileName, bajtovi, opcije);
                //FormaPesma = ofd.SafeFileName;
            }
        }
Example #24
0
        private void sound1_Click(object sender, EventArgs e)
        {
            int deviceNumberIn  = inputComboBox.SelectedIndex;
            int deviceNumberOut = outputComboBox.SelectedIndex;

            if (waveReader == null)
            {
                dialog = new OpenFileDialog();
                dialog.InitialDirectory = soundFolderTextBox.Text;
                dialog.Filter           = "Audio Files (.wav)|*.wav";

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    sound1.Text = dialog.FileName;
                    //sourceStream = new NAudio.Wave.WaveIn();
                    sourceOutStream = new NAudio.Wave.WaveOut();
                    sourceOutStream.DeviceNumber = deviceNumberOut;

                    //sourceStream.DeviceNumber = deviceNumber;
                    //sourceStream.WaveFormat = new NAudio.Wave.WaveFormat(44100, NAudio.Wave.WaveIn.GetCapabilities(deviceNumber).Channels);

                    //NAudio.Wave.WaveInProvider waveIn = new NAudio.Wave.WaveInProvider(sourceStream);

                    //output.Init(waveIn);

                    //sourceStream.StartRecording();
                    //output.Play();



                    waveReader = new NAudio.Wave.WaveFileReader(dialog.FileName);
                    sourceOutStream.Init(new NAudio.Wave.WaveChannel32(waveReader));
                    //output.Init(new NAudio.Wave.WaveChannel32(waveReader));
                    sourceOutStream.Play();
                    //output.Play();
                }
            }
            else
            {
                //Wenn schon vorhanden
                //Play sound
                waveReader = new NAudio.Wave.WaveFileReader(dialog.FileName);
                output.Init(new NAudio.Wave.WaveChannel32(waveReader));
                sourceOutStream.Init(new NAudio.Wave.WaveChannel32(waveReader));
                sourceOutStream.Play();
                //output.Play();
            }
        }
Example #25
0
        private void button1_Click(object sender, EventArgs e)
        {
            #region INICJOWANIE DŹWIĘKU
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "Wave File (*.wav)|*.wav;";
            if (open.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            wave   = new NAudio.Wave.WaveFileReader(open.FileName);
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(new NAudio.Wave.WaveChannel32(wave));
            output.Play();
            #endregion
        }
Example #26
0
        private void stopGame()
        {
            stopProcess();
            jumbledWordLabel.Text = "GAME OVER !";
            answerLabel.Text      = "PRESS RESTART\nTO TRY AGAIN !";

            String file = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\airhorn.wav";

            wave   = new NAudio.Wave.WaveFileReader(file);
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(new NAudio.Wave.WaveChannel32(wave));
            output.Play();

            MessageBox.Show("TIME'S UP !");
            MessageBox.Show("Total score: " + points);
        }
Example #27
0
 public int EnqueueSamples(int channels, int rate, byte[] samples, int frames)
 {
     if (buffer == null)
     {
         buffer = new NAudio.Wave.BufferedWaveProvider(new NAudio.Wave.WaveFormat(rate, channels));
         NAudio.Wave.DirectSoundOut dso = new NAudio.Wave.DirectSoundOut(70);
         dso.Init(buffer);
         dso.Play();
     }
     int space = buffer.BufferLength - buffer.BufferedBytes;
     if (space > samples.Length)
     {
         buffer.AddSamples(samples, 0, samples.Length);
         return frames;
     }
     return 0;
 }
Example #28
0
 void TimerClock(object sender, EventArgs e)
 {
     if (label2.Text != "—————————————————")
     {
         TimeSpan calc     = (DateTime.Now - Convert.ToDateTime(label2.Text));
         var      calc1    = Math.Round(calc.TotalSeconds, 0);
         TimeSpan halfhour = new TimeSpan(0, 30, 0);
         var      half     = halfhour.TotalSeconds;
         if ((calc1 % half) == 0)
         {
             Clock = new NAudio.Wave.WaveFileReader("Beep.wav");
             Play1 = new NAudio.Wave.DirectSoundOut();
             Play1.Init(new NAudio.Wave.WaveChannel32(Clock));
             Play1.Play();
         }
     }
 }
Example #29
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();

            open.Filter = "Wave File (*.wav)|*.wav;";
            if (open.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            DisposeWave();
            wave   = new NAudio.Wave.WaveFileReader(open.FileName);
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(new NAudio.Wave.WaveChannel32(wave));
            output.Play();

            button2.Enabled = true;
        }
Example #30
0
        private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();

            open.Filter = "MP3 File (*.mp3)|*.mp3;";
            if (open.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            DisposeWave();

            NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(open.FileName));
            stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(stream);
            output.Play();
            pauseMP3Button.Enabled = true;
        }
Example #31
0
        private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "MP3 File (*.mp3|*.mp3;";
            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }



            NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(dialog.FileName));
            NAudio.Wave.BlockAlignReductionStream stream = new NAudio.Wave.BlockAlignReductionStream(pcm);

            NAudio.Wave.DirectSoundOut output = new NAudio.Wave.DirectSoundOut();
            output.Init(stream);
            output.Play();
        }
        public void playTune(String result)
        {
            string file;
            if (result.Equals("WON"))
            {
                file = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\happy.wav";
            }
            else
            {
                file = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\sad.wav";
            }

            DisposeWave();

            wave = new NAudio.Wave.WaveFileReader(file);
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(new NAudio.Wave.WaveChannel32(wave));
            output.Play();
        }
Example #33
0
        public void OpenWAV()
        {
            OpenFileDialog open = new OpenFileDialog();

            open.Filter = "Wave File (*.wav)|*.wav;";
            if (open.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            DisposeWave();

            wave   = new NAudio.Wave.WaveFileReader(open.FileName);
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(new NAudio.Wave.WaveChannel32(wave));
            output.Play();

            PlayPauseEnabled = true;
        }
Example #34
0
        private void FInfoZaMec_Load(object sender, EventArgs e)
        {
            try
            {
                //TO DO : UCITATI I FORMATIRATI INFORMACIJE O OBA TIMA I O STADIONU I UPISATI U RTB..
                //prvo za domacina
                AuxLib.PrikaziDomacinaRTB(RTBDomacinInfo, domacin.Ime);
                AuxLib.PrikaziGostaRTB(RTBGostInfo, gost.Ime);
                AuxLib.PrikaziStadionRTB(RTBStadionInfo, stadion.Ime);



                //-------------------------

                //ucitavanje slika iz gridFS-a
                this.PBDomacinZastava.Image = AuxLib.LoadImageFromGridFS(domacin.Ime + "zastava");
                this.PBGostZastava.Image    = AuxLib.LoadImageFromGridFS(gost.Ime + "zastava");
                this.PBStadionZastava.Image = AuxLib.LoadImageFromGridFS(stadion.Ime + "stadion");
                //--------------------------

                //ucitamo himnu iz baze kao byte array
                byte[] domacinPesma = AuxLib.LoadSoundFromGridFS(domacin.Ime + "himna");
                //napravis stream
                MemoryStream domacinStream = new MemoryStream(domacinPesma);
                //prekines ako ima neka pesma prethodno ( za svaki slucaj );
                DisposeWave();
                //pcm pd strima
                NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(domacinStream));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);

                //init,hendler za drugu himnu i play
                output = new NAudio.Wave.DirectSoundOut();
                output.Init(stream);
                output.PlaybackStopped += output_PlaybackStopped;
                output.Play();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
        }
Example #35
0
        private void button9_Click(object sender, EventArgs e)
        {
            FileStream Tstream;
            OpenFileDialog ofd = new OpenFileDialog();
            var client = new MongoClient("mongodb://localhost");
            var database = client.GetDatabase("docs");
            var fs = new GridFSBucket(database);
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Tstream = new System.IO.FileStream(ofd.FileName, FileMode.Open, FileAccess.Read);
                //SoundPlayer simpleSound = new SoundPlayer(stream);
                //simpleSound.Play();
                var split = ofd.SafeFileName.Split('.');
                if(split[1] != "mp3")
                {
                    MessageBox.Show("Izaberite mp3 fajl!");
                    return;
                }
                DisposeWave();

                NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(Tstream));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
                // }
                // else if (open.FileName.EndsWith(".wav"))
                //{
                //    NAudio.Wave.WaveStream pcm = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));
                //    stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
                //}
                //else throw new InvalidOperationException("Not a correct audio file type.");

                output = new NAudio.Wave.DirectSoundOut();
                output.Init(stream);
                output.Play();

                //GridFSUploadOptions opcije = new GridFSUploadOptions();
                //opcije.ContentType = "audio/mp3";
                //opcije.ChunkSizeBytes = Convert.ToInt32(stream.Length)/4;

                //int duzina = Convert.ToInt32(stream.Length);
                //byte[] bajtovi = new byte[duzina];
                //stream.Seek(0, SeekOrigin.Begin);
                //int bytesRead = stream.Read(bajtovi, 0, duzina);

                //fs.UploadFromBytes(ofd.SafeFileName, bajtovi, opcije);
                //FormaPesma = ofd.SafeFileName;
            }
           
        }
        //string stopButtonState = "Stop";
        private void play_pause(object sender, EventArgs e)
        {
            if (output == null)
            {
                OpenFileDialog open = new OpenFileDialog();
                open.InitialDirectory = musicDir;
                open.Filter = "Audio File (*.mp3;*.wav)|*.mp3;*.wav;";
                if (open.ShowDialog() != DialogResult.OK) return;

                DisposeWave();

                if (open.FileName.EndsWith(".mp3"))
                {
                    NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(open.FileName));
                    stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
                }
                else if (open.FileName.EndsWith(".wav"))
                {
                    NAudio.Wave.WaveStream pcm = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));
                    stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
                }
                else throw new InvalidOperationException("Not a correct audio file type.");

                output = new NAudio.Wave.DirectSoundOut();
                output.Init(stream);
                output.Play();
            }
            else if (output != null)
            {
                if (output.PlaybackState == NAudio.Wave.PlaybackState.Playing) output.Pause();
                else if (output.PlaybackState == NAudio.Wave.PlaybackState.Paused) output.Play();
            }
        }
        private void jollyPicBox_Click_1(object sender, EventArgs e)
        {
            string file = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\TeacherWAV\" + lvlStr.ToLower() + ".wav";

            DisposeWave();

            wave = new NAudio.Wave.WaveFileReader(file);
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(new NAudio.Wave.WaveChannel32(wave));
            output.Play();
        }
Example #38
0
        private void playSound(String res)
        {
            string file;
            if (res.Equals("WON"))
            {
                file = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\Mario Coin.wav";
            }
            else
            {
                file = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\lose.wav";
            }

            DisposeWave();

            wave = new NAudio.Wave.WaveFileReader(file);
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(new NAudio.Wave.WaveChannel32(wave));
            output.Play();
        }
Example #39
0
        private void FInfoZaMec_Load(object sender, EventArgs e)
        {
            try
            {
                //vraca vraca objekte i upisuje podatke u richtextboxove
                domacin = AuxLib.PrikaziDomacinaRTB(this.RTBDomacinInfo, domacinIme);
                gost = AuxLib.PrikaziDomacinaRTB(this.RTBGostInfo, gostIme);
                stadion = AuxLib.PrikaziStadionRTB(this.RTBStadionInfo, domacin);
                //-------------------------

                //ucitavanje slika iz gridFS-a
                this.PBDomacinZastava.Image = AuxLib.LoadImageFromGridFS(this.domacinIme + "zastava");
                this.PBGostZastava.Image = AuxLib.LoadImageFromGridFS(this.gostIme + "zastava");
                this.PBStadionZastava.Image = AuxLib.LoadImageFromGridFS( stadion.Ime + "stadion");
                //--------------------------

                //ucitamo himnu iz baze kao byte array
                byte[] domacinPesma = AuxLib.LoadSoundFromGridFS(domacinIme+"himna");
                //napravis stream
                MemoryStream domacinStream = new MemoryStream(domacinPesma);
                //prekines ako ima neka pesma prethodno ( za svaki slucaj );
                DisposeWave();
                //pcm pd strima
                NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(domacinStream));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);

                //init,hendler za drugu himnu i play
                output = new NAudio.Wave.DirectSoundOut();
                output.Init(stream);
                output.PlaybackStopped += output_PlaybackStopped;
                output.Play();

            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
        }
        private void stopGame()
        {
            stopProcess();
            jumbledWordLabel.Text = "GAME OVER !";
            answerLabel.Text = "PRESS RESTART\nTO TRY AGAIN !";

            String file = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\airhorn.wav";
            wave = new NAudio.Wave.WaveFileReader(file);
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(new NAudio.Wave.WaveChannel32(wave));
            output.Play();

            MessageBox.Show("TIME'S UP !");
            MessageBox.Show("Total score: " + points);
        }
        public Soundsystem()
        {
            NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(
                new NAudio.Wave.Mp3FileReader("sounds/ambience-wind1.mp3"));

            ambience = new NAudio.Wave.BlockAlignReductionStream(pcm);

            pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(
                new NAudio.Wave.Mp3FileReader("music/zombi-drone.mp3"));

            drone = new NAudio.Wave.BlockAlignReductionStream(pcm);

            fire1 = new NAudio.Wave.WaveFileReader("sounds/gun-fire1.wav");
            fire2 = new NAudio.Wave.WaveFileReader("sounds/gun-fire2.wav");
            empty = new NAudio.Wave.WaveFileReader("sounds/gun-empty.wav");
            load = new NAudio.Wave.WaveFileReader("sounds/gun-load.wav");

            hitflesh1 = new NAudio.Wave.WaveFileReader("sounds/hit-flesh1.wav");
            hitflesh2 = new NAudio.Wave.WaveFileReader("sounds/hit-flesh2.wav");
            hitflesh3 = new NAudio.Wave.WaveFileReader("sounds/hit-flesh3.wav");
            hitmetal1 = new NAudio.Wave.WaveFileReader("sounds/hit-metal1.wav");
            hitmetal2 = new NAudio.Wave.WaveFileReader("sounds/hit-metal2.wav");
            hitmetal3 = new NAudio.Wave.WaveFileReader("sounds/hit-metal3.wav");
            hitrock = new NAudio.Wave.WaveFileReader("sounds/hit-rock1.wav");
            hitglass = new NAudio.Wave.WaveFileReader("sounds/hit-glass1.wav");

            walk1 = new NAudio.Wave.WaveFileReader("sounds/walk1.wav");
            walk2 = new NAudio.Wave.WaveFileReader("sounds/walk2.wav");
            walk3 = new NAudio.Wave.WaveFileReader("sounds/walk3.wav");
            walk4 = new NAudio.Wave.WaveFileReader("sounds/walk4.wav");
            walk5 = new NAudio.Wave.WaveFileReader("sounds/walk5.wav");
            walk6 = new NAudio.Wave.WaveFileReader("sounds/walk6.wav");
            walk7 = new NAudio.Wave.WaveFileReader("sounds/walk7.wav");
            walk8 = new NAudio.Wave.WaveFileReader("sounds/walk8.wav");

            zombi1 = new NAudio.Wave.WaveFileReader("sounds/zombi-moan1.wav");
            zombi2 = new NAudio.Wave.WaveFileReader("sounds/zombi-moan2.wav");
            zombi3 = new NAudio.Wave.WaveFileReader("sounds/zombi-moan3.wav");
            zombi4 = new NAudio.Wave.WaveFileReader("sounds/zombi-moan4.wav");
            zombi5 = new NAudio.Wave.WaveFileReader("sounds/zombi-moan5.wav");
            zombi6 = new NAudio.Wave.WaveFileReader("sounds/zombi-moan6.wav");
            zombi7 = new NAudio.Wave.WaveFileReader("sounds/zombi-moan7.wav");

            fire1_channel = new NAudio.Wave.WaveChannel32(fire1);
            fire1_channel.Volume = 0.0f;
            fire2_channel = new NAudio.Wave.WaveChannel32(fire2);
            fire2_channel.Volume = 0.0f;
            load_channel = new NAudio.Wave.WaveChannel32(load);
            load_channel.Volume = 0.0f;
            empty_channel = new NAudio.Wave.WaveChannel32(empty);
            empty_channel.Volume = 0.0f;

            hitglass_channel = new NAudio.Wave.WaveChannel32(hitglass);
            hitglass_channel.Volume = 0.0f;
            hitflesh1_channel = new NAudio.Wave.WaveChannel32(hitflesh1);
            hitflesh1_channel.Volume = 0.0f;
            hitflesh2_channel = new NAudio.Wave.WaveChannel32(hitflesh2);
            hitflesh2_channel.Volume = 0.0f;
            hitflesh3_channel = new NAudio.Wave.WaveChannel32(hitflesh3);
            hitflesh3_channel.Volume = 0.0f;
            hitrock_channel = new NAudio.Wave.WaveChannel32(hitrock);
            hitrock_channel.Volume = 0.0f;
            hitmetal1_channel = new NAudio.Wave.WaveChannel32(hitmetal1);
            hitmetal1_channel.Volume = 0.0f;
            hitmetal2_channel = new NAudio.Wave.WaveChannel32(hitmetal2);
            hitmetal2_channel.Volume = 0.0f;
            hitmetal3_channel = new NAudio.Wave.WaveChannel32(hitmetal3);
            hitmetal3_channel.Volume = 0.0f;

            walk1_channel = new NAudio.Wave.WaveChannel32(walk1);
            walk1_channel.Volume = 0.0f;
            walk2_channel = new NAudio.Wave.WaveChannel32(walk2);
            walk2_channel.Volume = 0.0f;
            walk3_channel = new NAudio.Wave.WaveChannel32(walk3);
            walk3_channel.Volume = 0.0f;
            walk4_channel = new NAudio.Wave.WaveChannel32(walk4);
            walk4_channel.Volume = 0.0f;
            walk5_channel = new NAudio.Wave.WaveChannel32(walk5);
            walk5_channel.Volume = 0.0f;
            walk6_channel = new NAudio.Wave.WaveChannel32(walk6);
            walk6_channel.Volume = 0.0f;
            walk7_channel = new NAudio.Wave.WaveChannel32(walk7);
            walk7_channel.Volume = 0.0f;
            walk8_channel = new NAudio.Wave.WaveChannel32(walk8);
            walk8_channel.Volume = 0.0f;

            zombi1_channel = new NAudio.Wave.WaveChannel32(zombi1);
            zombi1_channel.Volume = 0.0f;
            zombi2_channel = new NAudio.Wave.WaveChannel32(zombi2);
            zombi2_channel.Volume = 0.0f;

            zombi3_channel = new NAudio.Wave.WaveChannel32(zombi3);
            zombi3_channel.Volume = 0.0f;

            zombi4_channel = new NAudio.Wave.WaveChannel32(zombi4);
            zombi4_channel.Volume = 0.0f;

            zombi5_channel = new NAudio.Wave.WaveChannel32(zombi5);
            zombi5_channel.Volume = 0.0f;

            zombi6_channel = new NAudio.Wave.WaveChannel32(zombi6);
            zombi6_channel.Volume = 0.0f;

            zombi7_channel = new NAudio.Wave.WaveChannel32(zombi7);
            zombi7_channel.Volume = 0.0f;

            mikseri = new NAudio.Wave.WaveMixerStream32();

            ambience_channel = new NAudio.Wave.WaveChannel32(ambience);
            ambience_channel.Volume = 0.2f;

            drone_channel = new NAudio.Wave.WaveChannel32(drone);
            drone_channel.Volume = 0.5f;

            mikseri.AddInputStream(fire1_channel);
            mikseri.AddInputStream(fire2_channel);
            mikseri.AddInputStream(empty_channel);
            mikseri.AddInputStream(load_channel);

            mikseri.AddInputStream(hitflesh1_channel);
            mikseri.AddInputStream(hitflesh2_channel);
            mikseri.AddInputStream(hitflesh3_channel);
            mikseri.AddInputStream(hitmetal1_channel);
            mikseri.AddInputStream(hitmetal2_channel);
            mikseri.AddInputStream(hitmetal3_channel);
            mikseri.AddInputStream(hitrock_channel);
            mikseri.AddInputStream(hitglass_channel);

            mikseri.AddInputStream(walk1_channel);
            mikseri.AddInputStream(walk2_channel);
            mikseri.AddInputStream(walk3_channel);
            mikseri.AddInputStream(walk4_channel);
            mikseri.AddInputStream(walk5_channel);
            mikseri.AddInputStream(walk6_channel);
            mikseri.AddInputStream(walk7_channel);
            mikseri.AddInputStream(walk8_channel);

            mikseri.AddInputStream(zombi1_channel);
            mikseri.AddInputStream(zombi2_channel);
            mikseri.AddInputStream(zombi3_channel);
            mikseri.AddInputStream(zombi4_channel);
            mikseri.AddInputStream(zombi5_channel);
            mikseri.AddInputStream(zombi6_channel);
            mikseri.AddInputStream(zombi7_channel);

            mikseri.AddInputStream(ambience_channel);
            mikseri.AddInputStream(drone_channel);

            mikseri.AutoStop = false;

            output = new NAudio.Wave.DirectSoundOut();
            output.Init(mikseri);

            soundson = true;
            output.Play();
        }
        private void jollyPicBox_Click(object sender, EventArgs e)
        {
            string file = "Class" + LoginForm.classSec + "_kidAudio/" + lvlStr.ToLower() + ".wav";

            DisposeWave();

            wave = new NAudio.Wave.WaveFileReader(file);
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(new NAudio.Wave.WaveChannel32(wave));
            output.Play();
        }
Example #43
0
        private void button10_Click(object sender, EventArgs e)
        {
            var client = new MongoClient("mongodb://localhost");
            var database = client.GetDatabase("docs");
            var fs = new GridFSBucket(database);

            //var aaa = fs.Find()
            var test = fs.DownloadAsBytesByName("Muzika");

            MemoryStream memStream = new MemoryStream(test);

            //OpenFileDialog open = new OpenFileDialog();
            //open.Filter = "Audio File (*.mp3;*.wav)|*.mp3;*.wav;";
            //if (open.ShowDialog() != DialogResult.OK) return;

            DisposeWave();

               // if (open.FileName.EndsWith(".mp3"))
               // {
                NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(memStream));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
               // }
               // else if (open.FileName.EndsWith(".wav"))
            //{
            //    NAudio.Wave.WaveStream pcm = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));
            //    stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
            //}
            //else throw new InvalidOperationException("Not a correct audio file type.");

            output = new NAudio.Wave.DirectSoundOut();
            output.Init(stream);
            output.Play();
        }
Example #44
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            seconds = seconds - 1;
            if(seconds == 0)
            {
                stopProcess();
                questLabel.Text = "GAME OVER !";
                statusLabel.Text = "PRESS RESTART\nTO TRY AGAIN !";

                String file = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\airhorn.wav";
                wave = new NAudio.Wave.WaveFileReader(file);
                output = new NAudio.Wave.DirectSoundOut();
                output.Init(new NAudio.Wave.WaveChannel32(wave));
                output.Play();

                MessageBox.Show("TIME'S UP !");
                MessageBox.Show("Total score: " + points);
            }
            timerLabel.Text = Convert.ToString(seconds);
        }
        private void buttonPlayRecording_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "Wave File (*.wav)|*.wav;";
            if (open.ShowDialog() != DialogResult.OK) return;
            textBoxRecordingLocation.Text = open.FileName;

            DisposeWave();

            waveReader = new NAudio.Wave.MediaFoundationReader(open.FileName);

            output = new NAudio.Wave.DirectSoundOut();
            //output.Init(new NAudio.Wave.WaveChannel32(wave));
            output.Init(waveReader);
            output.Play();
            //pauseButton.Enabled = true;
        }
        //Plays/Repeats the audio of the letter
        private void repeatBtn_Click(object sender, EventArgs e)
        {
            String filename = "Class" + LoginForm.classSec + "_kidAudio/" + letters[curPos] + ".wav";
            DisposeWave();

            wave = new NAudio.Wave.WaveFileReader(filename);
            output = new NAudio.Wave.DirectSoundOut();
            output.Init(new NAudio.Wave.WaveChannel32(wave));
            output.Play();
        }
Example #47
0
        //druga himna
        void output_PlaybackStopped(object sender, NAudio.Wave.StoppedEventArgs e)
        {
            if(notClosed)
            {
                try
                {
                    DisposeWave();

                    byte[] gostPesma = AuxLib.LoadSoundFromGridFS(gost.Ime + "himna");
                    MemoryStream gostStream = new MemoryStream(gostPesma);
                    NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(gostStream));
                    stream = new NAudio.Wave.BlockAlignReductionStream(pcm);

                    output = new NAudio.Wave.DirectSoundOut();
                    output.Init(stream);

                    output.Play();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
        }
Example #48
0
        private void FInfoZaMec_Load(object sender, EventArgs e)
        {
            try
            {
                //TO DO : UCITATI I FORMATIRATI INFORMACIJE O OBA TIMA I O STADIONU I UPISATI U RTB..
                //prvo za domacina
                AuxLib.PrikaziDomacinaRTB(RTBDomacinInfo, domacin.Ime);
                AuxLib.PrikaziGostaRTB(RTBGostInfo, gost.Ime);
                AuxLib.PrikaziStadionRTB(RTBStadionInfo, stadion.Ime);



                //-------------------------

                //ucitavanje slika iz gridFS-a
                this.PBDomacinZastava.Image = AuxLib.LoadImageFromGridFS(domacin.Ime + "zastava");
                this.PBGostZastava.Image = AuxLib.LoadImageFromGridFS(gost.Ime + "zastava");
                this.PBStadionZastava.Image = AuxLib.LoadImageFromGridFS(stadion.Ime + "stadion");
                //--------------------------

                //ucitamo himnu iz baze kao byte array
                byte[] domacinPesma = AuxLib.LoadSoundFromGridFS(domacin.Ime+"himna");
                //napravis stream
                MemoryStream domacinStream = new MemoryStream(domacinPesma);
                //prekines ako ima neka pesma prethodno ( za svaki slucaj );
                DisposeWave();
                //pcm pd strima
                NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(domacinStream));
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);

                //init,hendler za drugu himnu i play
                output = new NAudio.Wave.DirectSoundOut();
                output.Init(stream);
                output.PlaybackStopped += output_PlaybackStopped;
                output.Play();
                
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
        }
Example #49
0
        private void buttonRecStart_Click(object sender, EventArgs e)
        {
            if (listViewSources.SelectedItems.Count == 0)
            {
                Console.WriteLine("No device selected.");
                return;
            }

            int deviceNumber = listViewSources.SelectedItems[0].Index;
            labelRecDevice.Text = deviceNumber.ToString();

            sourceStream = new NAudio.Wave.WaveIn();
            sourceStream.DeviceNumber = deviceNumber;
            sourceStream.WaveFormat = new NAudio.Wave.WaveFormat(44100, NAudio.Wave.WaveIn.GetCapabilities(deviceNumber).Channels);
            sourceStream.DataAvailable += new EventHandler<NAudio.Wave.WaveInEventArgs>(waveIn_DataAvailable);
            sourceStream.StartRecording();

            if (checkBoxPlayback.Checked)
            {
                NAudio.Wave.WaveInProvider waveIn = new NAudio.Wave.WaveInProvider(sourceStream);
                waveOut = new NAudio.Wave.DirectSoundOut(NAudio.Wave.WaveOut.GetCapabilities(outputDevice).ProductGuid);
                waveOut.Init(waveIn);
                waveOut.Play();
            }
            else
            {
                NAudio.Wave.WaveIn waveIn = new NAudio.Wave.WaveIn();
            }

            pictureBoxRecording.BackColor = Color.Red;
        }