コード例 #1
0
 private static void PlayWav(string wavFile)
 {
     Task.Run(() =>
     {
         var player = new System.Media.SoundPlayer {SoundLocation = wavFile};
         player.PlaySync();
     });
 }
コード例 #2
0
ファイル: SonidosZinLock.cs プロジェクト: tetradog/ZinLock
 public static void Play(Sonidos sonido)
 {
     byte[] musica = Obtener(sonido.ToString());
     string pathSonido;
     //play sonido
     pathSonido = DameRutaTemporal(musica,sonido.ToString());
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(pathSonido);
     player.PlaySync();
 }
コード例 #3
0
ファイル: Common.cs プロジェクト: mard/Uploader
 public static void PlaySound(ConfigurationProfile profile)
 {
     if (profile.SoundEnabled.IsTrue())
     {
         using (var p = new System.Media.SoundPlayer())
         {
             p.SoundLocation = Path.Combine(Globals.ExecutableDirectory, profile.Soundfile);
             p.PlaySync();
         }
     }
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: tetradog/ZinLock
 public static void Main(string[] args)
 {
     bool infinito = args[1] == "-i";
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(args[0]);
     Console.WriteLine("Plaing:"+args[0]);
     if (!infinito)
         player.PlaySync();
     else{
         player.PlayLooping();
         for(;;);
     }
 }
コード例 #5
0
ファイル: SoundPlayer.cs プロジェクト: sandalkuilang/texto
 public void PlayAsync(string url)
 {
     System.Threading.EventWaitHandle wait = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.AutoReset);
     Task.Factory.StartNew(() =>
     {
         System.Media.SoundPlayer player = new System.Media.SoundPlayer(url);
         player.PlaySync();
         wait.Set();
     }).ContinueWith(x =>
     {
         wait.WaitOne();
     });
 }
コード例 #6
0
ファイル: Form1.cs プロジェクト: ReneeHuh/CountDownClock
        public void Fisished()
        {
            btStart.Text = "Start";
            btStopReset.Text = "Reset";

            IndicatorOn(false);
            CDTimer.Enabled = false;
            TimeToCountDown.Clear();
            DisplayRefesh();

            int sel = Properties.Settings.Default.WavFileSelected;
            string location = CDCControls.WavLocation[sel];
            System.Media.SoundPlayer player = new System.Media.SoundPlayer(location);

            for (int i = 0; i < Properties.Settings.Default.WavPlayTimes; i++)
            {
                player.PlaySync();
            }
        }
コード例 #7
0
ファイル: SoundPlayer.cs プロジェクト: IsaacSanch/KoruptLib
        public static void PlayCachedSound(this UnmanagedMemoryStream resource)
        {
            if (ReferenceEquals(SoundCache, null))
                SoundCache = new Dictionary<int, MemoryStream>();

            if (!SoundCache.ContainsKey(resource.GetHashCode()))
            {
                resource.Position = 0;
                SoundCache.Add(resource.GetHashCode(),
                    new MemoryStream(new BinaryReader(resource).ReadBytes((int)resource.Length))
                );
            }

            System.Media.SoundPlayer sp = new System.Media.SoundPlayer(SoundCache[resource.GetHashCode()]);
            try { sp.PlaySync(); }
            catch { }
            finally
            {
                sp = null;
                SoundCache[resource.GetHashCode()].Position = 0;
            }
        }
コード例 #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            var soundPlayer = new System.Media.SoundPlayer("Wobbler.wav");

            soundPlayer.PlaySync();
        }
コード例 #9
0
ファイル: CountDown.cs プロジェクト: ReneeHuh/CountDownClock
        public void Fisished()
        {
            Timer.Enabled = false;
            Time.Clear();

            TimeChangedEventArgs e = new TimeChangedEventArgs(Time.ToString());
            DelegateExpansion.CrossInvoke(CountDownChanged, this, e);
            //CountDownChanged(this,e) ;

            int sel = Properties.Settings.Default.WavFileSelected;
            string location = CDCControls.WavLocation[sel];
            System.Media.SoundPlayer player = new System.Media.SoundPlayer(location);

            for (int i = 0; i < Properties.Settings.Default.WavPlayTimes; i++)
            {
                player.PlaySync();
            }
        }
コード例 #10
0
        static void Main(string[] args)
        {
            int[]    printMinuetNumber = new int[16];                                                                   // initialize an array of 16
            string[] filesMinuet       = new string[16];                                                                // initialize a string of 16
            int[,] MinuetNumber = new int[, ]                                                                           // initialize an array of the numbers from minuet

            {
                { 96, 22, 141, 41, 105, 122, 11, 30, 70, 121, 26, 9, 122, 49, 109, 14 },
                { 32, 6, 128, 63, 146, 46, 134, 81, 117, 39, 126, 56, 174, 18, 116, 83 },
                { 69, 95, 158, 13, 153, 55, 110, 24, 66, 139, 15, 132, 73, 58, 145, 79 },
                { 40, 17, 113, 85, 161, 2, 159, 100, 90, 176, 7, 34, 67, 160, 52, 170 },
                { 148, 74, 163, 45, 80, 97, 36, 107, 25, 143, 64, 125, 76, 137, 1, 93 },
                { 104, 157, 27, 167, 154, 68, 118, 91, 138, 71, 150, 29, 101, 162, 23, 151 },
                { 152, 60, 171, 53, 99, 133, 21, 127, 16, 155, 57, 175, 43, 168, 89, 172 },
                { 119, 84, 114, 50, 140, 86, 169, 94, 120, 88, 48, 166, 51, 115, 72, 111 },
                { 98, 142, 42, 156, 75, 129, 62, 123, 65, 77, 19, 82, 137, 38, 149, 8 },
                { 3, 87, 165, 61, 135, 47, 147, 33, 102, 4, 31, 164, 144, 59, 173, 78 },
                { 54, 130, 10, 103, 28, 37, 106, 5, 35, 20, 108, 92, 12, 124, 44, 131 },
            };

            Random ran = new Random();                                                                                  // using random


            for (int i = 0; i < MinuetNumber.GetLength(0); i++)                                                 // for loop to loop through dimension 1
            {
                for (int j = 0; j < MinuetNumber.GetLength(1); j++)                                             // for loop to loop through dimension 2
                {
                    int Dice = ran.Next(0, 10);                                                                 // initialize a Dice that rolls between 0 and 10
                    printMinuetNumber[j] = MinuetNumber[Dice, j];                                               // stores the chosen number from first row to printMinuetNumber
                }
            }

            Console.WriteLine("This is which Minuet files that are played ");
            for (int i = 0; i < 16; i++)                                                                               // for loop to print out which numbers that are beeing played
            {
                Console.Write(printMinuetNumber[i] + " ");
            }

            Console.WriteLine();

            for (int i = 0; i < filesMinuet.Length; i++)                                                               // loops through the sound files that has the numbers from printMinuetNumber
            {
                filesMinuet[i] = $@"C:\Users\mathi\source\repos\Mozart\filesMinuet\M{printMinuetNumber[i]}.wav";
            }

            System.Media.SoundPlayer soundPlayer = new System.Media.SoundPlayer();                                    // initialize our sound player

            foreach (string soundtrack in filesMinuet)                                                                // playes the sound files that are stored in filesMinuet
            {
                soundPlayer.SoundLocation = soundtrack;
                soundPlayer.Load();
                soundPlayer.PlaySync();
            }

            int[,] trioNumber = new int[, ]
            {
                { 72, 6, 59, 25, 81, 41, 89, 13, 36, 5, 46, 79, 30, 95, 19, 66 },
                { 56, 82, 42, 74, 14, 7, 26, 71, 76, 20, 64, 84, 8, 35, 47, 88 },
                { 75, 39, 54, 1, 65, 43, 15, 80, 9, 34, 93, 48, 69, 58, 90, 21 },
                { 40, 73, 16, 68, 29, 55, 2, 61, 22, 57, 49, 77, 57, 87, 33, 10 },
                { 83, 3, 28, 53, 37, 17, 44, 70, 63, 85, 32, 96, 12, 23, 50, 91 },
                { 18, 45, 62, 38, 4, 27, 52, 94, 11, 92, 24, 86, 51, 60, 78, 31 },
            };


            string[] FilesTrio = new string[16];
            int[]    printTrio = new int[16];


            for (int i = 0; i < trioNumber.GetLength(0); i++)
            {
                for (int j = 0; j < trioNumber.GetLength(1); j++)
                {
                    int dice2 = ran.Next(0, 6);
                    printTrio[j] = trioNumber[dice2, j];
                }
            }

            Console.Clear();
            Console.WriteLine("This is which Trio files that are played ");
            for (int i = 0; i < 16; i++)
            {
                Console.Write(printTrio[i] + " ");
            }

            for (int i = 0; i < FilesTrio.Length; i++)
            {
                FilesTrio[i] = $@"C:\Users\mathi\source\repos\Mozart\filesTrio\T{printTrio[i]}.wav";
            }

            System.Media.SoundPlayer soundPlayer1 = new System.Media.SoundPlayer();

            foreach (string soundtrack in FilesTrio)
            {
                soundPlayer1.SoundLocation = soundtrack;
                soundPlayer1.Load();
                soundPlayer1.PlaySync();
            }
        }
コード例 #11
0
ファイル: MediaPlayer.cs プロジェクト: Niller303/SpeechTest
 public void Play()
 {
     soundPlayer.PlaySync();
 }
コード例 #12
0
ファイル: TABA.cs プロジェクト: Blissgig/TakeABow
        private void PlayApplause()
        {
            try
            {
                Random objRandom = new Random();
                UnmanagedMemoryStream RandomSound = Properties.Resources.Crickets;
                byte bRandom = Convert.ToByte(objRandom.Next(0, 4));

                switch (bRandom)
                {
                    case 0:
                        RandomSound = Properties.Resources.Crickets;
                        break;

                    case 1:
                        RandomSound = Properties.Resources.Applauding_People_Sound;
                        break;

                    case 2:
                        RandomSound = Properties.Resources.Crowd_Applause;
                        break;

                    case 3:
                        RandomSound = Properties.Resources.Polite_Applause;
                        break;

                    case 4:
                        RandomSound = Properties.Resources.Small_Room;
                        break;
                }

                System.Media.SoundPlayer ApplausePlayer = new System.Media.SoundPlayer(RandomSound);  //Properties.Resources.Crickets);

                ApplausePlayer.PlaySync(); //To insure that the varaible IsPlaying doesn't get reset until the sound completes, as opposed to .Play()
                IsAudioPlaying = false;    //only attempt a new sound when this one has stopped
                ApplausePlayer = null;
            }
            catch (Exception ex)
            {
                LogException(ex);
            }
            finally
            {
                GC.Collect();
            }
        }
コード例 #13
0
        void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            isup = 1;
            //stage 0
            //------------------------------------------------------------------
            if (stage == 0)
            {
                if (oah == 0)
                {
                    if (e.X >= 850 && e.Y >= 500 && e.X <= 850 + start.Width && e.Y <= 500 + start.Height / 2)
                    {
                        stage     = 2;
                        this.Text = "Level 1";
                    }
                    if (e.X >= 850 && e.Y >= 600 && e.X <= 850 + options.Width && e.Y <= 600 + options.Height)
                    {
                        oah = 1;
                    }

                    /*if (e.X >= 850 && e.Y >= 800 && e.X <= 850 + account.Width && e.Y <= 800 + account.Height)
                     * {
                     *  oah = 2;
                     * }
                     * if (e.X >= 850 && e.Y >= 700 && e.X <= 850 + highscores.Width && e.Y <= 700 + highscores.Height)
                     * {
                     *  oah = 3;
                     * }*/
                }
                if (oah == 1)
                {
                    if (e.X >= 600 && e.Y >= 500 && e.X <= 900 && e.Y <= 560)
                    {
                        if (mf == 0)
                        {
                            mon = new Bitmap("D://Cs//CS 232//Assignments//Minigame1//Sources//On.bmp");
                            mon.MakeTransparent(Color.White);
                            moff = new Bitmap("D://Cs//CS 232//Assignments//Minigame1//Sources//Offg.bmp");
                            moff.MakeTransparent(Color.White);
                            mf = 1;
                            player.Stop();
                        }
                        else if (mf == 1)
                        {
                            mon = new Bitmap("D://Cs//CS 232//Assignments//Minigame1//Sources//Ong.bmp");
                            mon.MakeTransparent(Color.White);
                            moff = new Bitmap("D://Cs//CS 232//Assignments//Minigame1//Sources//Off.bmp");
                            moff.MakeTransparent(Color.White);
                            mf = 0;
                            player.Play();
                        }
                    }
                    if (e.X >= 600 && e.Y >= 700 && e.X <= 700 && e.Y <= 760)
                    {
                        bgc = Color.White;
                    }
                    if (e.X >= 750 && e.Y >= 700 && e.X <= 850 && e.Y <= 760)
                    {
                        bgc = Color.Black;
                    }
                    if (e.X >= 900 && e.Y >= 700 && e.X <= 1000 && e.Y <= 760)
                    {
                        bgc = Color.Blue;
                    }
                    if (e.X >= 1050 && e.Y >= 700 && e.X <= 1150 && e.Y <= 760)
                    {
                        bgc = Color.Brown;
                    }
                    if (e.X >= 1100 && e.Y >= this.ClientSize.Height - 100 && e.X <= 1200 && e.Y <= this.ClientSize.Height - 40)
                    {
                        oah = 0;
                    }
                }
                //------------------------------------------------------------------
            }
            //Stage 1
            //----------------------------------------------------------------------
            if (stage == 1)
            {
                //Balls
                for (int i = 0; i < 4; i++)
                {
                    if (e.X >= st1b[i].posx && e.Y >= st1b[i].posy && e.X <= st1b[i].posx + 50 && e.Y <= st1b[i].posy + 50)
                    {
                        ex   = e.X;
                        ey   = e.Y;
                        bn   = i;
                        boxx = (st1b[bn].posx - 20 - s1t1) / 100;
                        boxy = (st1b[bn].posy - 10 - s1t2) / 70;
                        break;
                    }
                }
                //Back
                if (e.X >= 1100 && e.Y >= this.ClientSize.Height - 100 && e.X <= 1200 && e.Y <= this.ClientSize.Height - 40)
                {
                    string            message = "Do You Really Want To Exit And Remove All Progress";
                    string            caption = "You Will Lose";
                    MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                    DialogResult      result;
                    result = MessageBox.Show(message, caption, buttons);
                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        stage = 0;
                        oah   = 0;
                        for (int i = 0; i < st1b.Count; i++)
                        {
                            st1b.RemoveAt(i);
                        }
                        int[] s1posx = { -1, -1, -1, -1 };
                        int[] s1posy = { -1, -1, -1, -1 };
                        int   a, b;
                        for (int z = 0; z < 4; z++)
                        {
                            for (; ;)
                            {
                                a = r.Next(6);
                                b = r.Next(6);
                                if (!isExist(a, b, s1posx, s1posy))
                                {
                                    s1posx[z] = a;
                                    s1posy[z] = b;
                                    break;
                                }
                            }
                        }
                        int k = 0;
                        for (int i = 0; i < 4; i++)
                        {
                            stage1balls pnn = new stage1balls();
                            pnn.posx = s1posx[k] * 100 + s1t1 + 20;
                            pnn.posy = s1posy[k] * 70 + s1t2 + 10;
                            if (i == 0)
                            {
                                pnn.iconnect = 2;
                            }
                            if (i == 1)
                            {
                                pnn.iconnect = 3;
                            }
                            if (i == 2)
                            {
                                pnn.iconnect = 0;
                            }
                            if (i == 3)
                            {
                                pnn.iconnect = 1;
                            }
                            st1b.Add(pnn);
                            k++;
                        }
                    }
                }
                //next
                if (e.X >= 1300 && e.Y >= this.ClientSize.Height - 100 && e.X <= 1500 && e.Y <= this.ClientSize.Height - 40)
                {
                    stage = 2;
                }
            }
            //----------------------------------------------------------------------
            //Stage 2
            //----------------------------------------------------------------------
            //back
            if (stage == 2)
            {
                if (e.X >= 1100 && e.Y >= this.ClientSize.Height - 100 && e.X <= 1200 && e.Y <= this.ClientSize.Height - 40)
                {
                    string            message = "Do You Really Want To Exit And Remove All Progress";
                    string            caption = "You Will Lose";
                    MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                    DialogResult      result;
                    result = MessageBox.Show(message, caption, buttons);
                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        stage = 0;
                        oah   = 0;
                    }
                }
                if (e.X >= 600 && e.Y >= 250 && e.X <= 850 && e.Y <= 500)
                {
                    b = 1;
                    drawbuffer(this.CreateGraphics());
                    sndPlayer.SoundLocation = "D://Cs//CS 232//Assignments//Minigame1//Sources//1.wav";
                    sndPlayer.PlaySync();
                    if (fstart == 1)
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            if (patternuser[i] == -1)
                            {
                                patternuser[i] = 0;
                                break;
                            }
                        }
                    }
                }
                if (e.X >= 860 && e.Y >= 250 && e.X <= 1110 && e.Y <= 500)
                {
                    re = 1;
                    drawbuffer(this.CreateGraphics());
                    sndPlayer.SoundLocation = "D://Cs//CS 232//Assignments//Minigame1//Sources//2.wav";
                    sndPlayer.PlaySync();
                    if (fstart == 1)
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            if (patternuser[i] == -1)
                            {
                                patternuser[i] = 1;
                                break;
                            }
                        }
                    }
                }
                if (e.X >= 600 && e.Y >= 510 && e.X <= 850 && e.Y <= 760)
                {
                    gr = 1;
                    drawbuffer(this.CreateGraphics());
                    sndPlayer.SoundLocation = "D://Cs//CS 232//Assignments//Minigame1//Sources//3.wav";
                    sndPlayer.PlaySync();
                    if (fstart == 1)
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            if (patternuser[i] == -1)
                            {
                                patternuser[i] = 2;
                                break;
                            }
                        }
                    }
                }
                if (e.X >= 860 && e.Y >= 510 && e.X <= 1110 && e.Y <= 760)
                {
                    y = 1;
                    drawbuffer(this.CreateGraphics());
                    sndPlayer.SoundLocation = "D://Cs//CS 232//Assignments//Minigame1//Sources//4.wav";
                    sndPlayer.PlaySync();
                    if (fstart == 1)
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            if (patternuser[i] == -1)
                            {
                                patternuser[i] = 3;
                                break;
                            }
                        }
                    }
                }
                if (e.X >= 50 && e.Y >= 50 && e.X <= 150 && e.Y <= 150 && fstart == 0)
                {
                    stage2music();
                    fstart = 1;
                }
                if (win2 == 1)
                {
                    if (e.X >= 1300 && e.Y >= this.ClientSize.Height - 100 && e.X <= 1500 && e.Y <= this.ClientSize.Height - 40)
                    {
                        stage = 3;
                    }
                }
            }
            //-------------------------------------------------------------------------------------------
            //Stage 3
            //-------------------------------------------------------------------------------------------
            if (stage == 3)
            {
                if (e.X >= 1100 && e.Y >= this.ClientSize.Height - 100 && e.X <= 1200 && e.Y <= this.ClientSize.Height - 40)
                {
                    string            message = "Do You Really Want To Exit And Remove All Progress";
                    string            caption = "You Will Lose";
                    MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                    DialogResult      result;
                    result = MessageBox.Show(message, caption, buttons);
                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        stage = 0;
                        oah   = 0;
                    }
                }
                if (e.Button == MouseButtons.Left)
                {
                    for (int i = 0; i < pers.Count; i++)
                    {
                        if (ishit(e.X, e.Y, pers[i].x, pers[i].y))
                        {
                            if (pers[i].x > 700 && pers[i].y == 630)
                            {
                                pers[i].x = putx3;
                                pers[i].y = 640;
                                putx3    += 15;
                                nop--;
                                nopr++;
                                for (int k = 0; i < 2; i++)
                                {
                                    if (pn[k] == i)
                                    {
                                        pn[k] = -1;
                                    }
                                }
                                putx -= 15;
                            }
                            else if (nop < 2 && ((shipx < 700 && pers[i].x < 700) || (shipx > 700 && pers[i].x > 700)))
                            {
                                if (shipx > 700 && pers[i].x > 700)
                                {
                                    putx3 -= 15;
                                    nopr--;
                                }
                                else
                                {
                                    nopl--;
                                }
                                putx     += 15;
                                pers[i].x = putx;
                                pers[i].y = 630;
                                pn[nop]   = i;
                                nop++;
                            }
                            break;
                        }
                    }
                    for (int i = 0; i < enem.Count; i++)
                    {
                        if (ishit(e.X, e.Y, enem[i].x, enem[i].y))
                        {
                            if (enem[i].x > 700 && enem[i].y == 630)
                            {
                                enem[i].x = putx4;
                                enem[i].y = 640;
                                putx4    -= 30;
                                nop--;
                                noer++;
                                for (int k = 0; k < 2; k++)
                                {
                                    if (en[k] == i)
                                    {
                                        en[k] = -1;
                                    }
                                }
                                putx2 += 30;
                            }
                            else if (nop < 2 && ((enem[i].x < 700 && shipx < 700) || (enem[i].x > 700 && shipx > 700)))
                            {
                                if (shipx > 700 && enem[i].x > 700)
                                {
                                    putx4 += 30;
                                    noer--;
                                }
                                else
                                {
                                    noel--;
                                }
                                putx2    -= 30;
                                enem[i].x = putx2;
                                enem[i].y = 630;
                                en[nop]   = i;
                                nop++;
                            }
                            break;
                        }
                    }
                }
                if (e.Button == MouseButtons.Right)
                {
                    if (e.X >= 1250)
                    {
                        right = 1;
                    }
                    else if (e.X <= 630)
                    {
                        left = 1;
                    }
                }
            }
        }
コード例 #14
0
        //public static void ARRAY1()
        //{
        //    //            Lav et array med plads til 9 elementer.Indsæt tallene 1-9 ved hjælp af en løkke.

        //    //-	Find tallet på index plads nr. 5 vha en løkke

        //    //-	Ændr dette element så det indeholder den dobbelte værdi af den forrige

        //    int[] numbers = new int[9];

        //    for (int i = 0; i < numbers.Length; i++)
        //    {
        //        numbers[i] = i;
        //        Console.WriteLine(numbers[i]);

        //        Console.WriteLine(numbers[5]);
        //        Console.ReadLine(); //gør så at jeg skal trykke enter før vinduet lukker.
        //        Console.ReadLine(); //gør så at jeg skal trykke enter før vinduet lukker.
        //    }
        //}

        //public static void ARRAYS()
        //{
        //    //            Øvelse 1
        //    //Skriv en applikation program, som prompter en bruger for brugernavn og password.
        //    //•	Hvis brugeren er kendt, skal der spørges om password.
        //    //•	Hvis brugeren ikke er kendt, skal der gives en meddelelse om at brugeren ikke har adgang til systemet.
        //    //•	Password må kun forsøges 3 gange, herefter afsluttes.
        //    //•	Programmet skal kunne håndtere mindst 5 brugere med tilhørende password.
        //    //•	Brugere skal oprettes i et array.
        //    //Tip: lav evt.et array til brugernavne og et array til passwords og tjek på index
        //    string[] names = new string[5] { "Liza", "Ireen", "Sasha", "Jo", "Mario" };

        //    int[] passwords = new int[5] { 123, 456, 789, 101, 112 };

        //    Console.WriteLine("What is you name:  ");
        //    string CostumerName = (Console.ReadLine());

        //    for (int i = 0; i < 5; i++)
        //    {
        //        if (CostumerName == names[i])
        //        {
        //            for (int j = 0; j < 3; j++) //jeg har 3 forsøg til at logge ind, derfor denne linje
        //            {
        //                Console.WriteLine("Write your password: "******"you typed the right password, you used " + j + "attemps");
        //                }
        //                else

        //                {
        //                    Console.WriteLine("You are not in the system");
        //                }
        //            }
        //        }
        //        else
        //        {
        //            Console.WriteLine("You are not in the system");


        //        }
        //    }
        //}
        ////public static void ARRAYSOGBUBBLESORT()
        ////{
        ////    //            Opgave a) – Oprettelse af et array og tildeling af tilfældig værdi
        ////    //1. Opret et array med plads til 100 elementer.
        ////    //int[] tal = new int[100];
        ////    int[] elementer = new int[100];

        ////    //            2.Nu skal der indsættes tilfældige tal i arrayet på alle pladser, dette kan gøres
        ////    //ved at bruge en forløkke, i stedet for 100 gange at indsætte et tal i arrayet.
        ////    //En for-løkke kræver en start - og en stopværdi for at kunne køre.Start værdien i denne løkke kan
        ////    //passende være 0, da et array jo altid starter på index 0.Stopværdien er 99, da der startes med 0.
        ////    //Det er rigtig usmart at skrive 99 som stopværdi en for-løkke, for hvis vi vil ændre på arrayets
        ////    //størrelse skal vi rette mange steder i vores kode, derfor at det smartere at bruge den indbyggede
        ////    //Length metode, der findes på et array.
        ////    //for (int i = 0; i < tal.Length; i++)
        ////    //{
        ////    //    //Her skal der indsættes tilfældige tal
        ////    //    //for alle elementer i arrayet
        ////    //}
        ////    Random random = new Random();

        ////    for (int i = 0; i < elementer.Length; i++)
        ////    {
        ////        elementer[i] = random.Next(0, 99);
        ////        Console.WriteLine(elementer[i]);

        ////    }
        ////    Console.ReadLine(); //gør så at jeg skal trykke enter før vinduet lukker.
        ////    Console.ReadLine(); //gør så at jeg skal trykke enter før vinduet lukker.

        ////}
        //public static void LISTE()
        //{
        //    // Lav en liste listeB bestående af de lige tal mellem 1-20 -
        //    //Fjern alle tal som 3 går op i -	Hvor mange elementer er der nu i listen? -
        //    //Indsæt værdien 17 på plads nr. 3 -	Lav en ny liste der består af listeB’s elementer –
        //    //men i omvendt rækkefølge

        //    List<int> numbers = new List<int>();

        //    for (int i = 0; i < 20-2; i++)
        //    {
        //        if (i % 2 == 0)
        //        {
        //            numbers.Add(i);
        //            Console.WriteLine(i);

        //        }
        //    }
        //    for (int i = 0; i< numbers.Count; i++)
        //    {
        //        if (numbers[i] % 3 == 0)
        //        {
        //            numbers.RemoveAt(i);


        //    }
        //}
        //numbers.Insert(3, 17);
        //foreach (int i in numbers)
        //    Console.WriteLine(i);

        //List<int> reverslist = numbers;
        //reverslist.Reverse();
        //foreach (int i in reverslist)
        //    Console.WriteLine(i);
        //Console.ReadKey();

        //public static void LOTTO()
        //{
        //    //            I denne opgave skal i bruge en tilfældighedsgenerator.
        //    //Man kan genere tilfældige tal i C# vha Random klassen. Nedenstående giver et tilfældigt tal mellem 1 og 100.


        //    //Random r = new Random();

        //    //        int ran = r.Next(1, 100);

        //    //-	Lav et array der indeholder 7 tilfældige lottoTal mellem 1 og 20. Dette er vinder-kuponen.

        //    //-	Lav nu endnu et array med 7 tal der repræsenterer en brugers kupon.

        //    //-	I kan lade brugeren indtaste de 7 tal, eller i kan ”hardcode” brugerens kupon.

        //    //-	Undersøg hvor mange rigtige tal der er på brugerens kupon, og udbetal forskellige gevinster
        //    //på kuponer der har mere end to rigtige.


        //    int[] kupon = new int[7];
        //    Random r = new Random();
        //    int ran = r.Next(1, 20);
        //    for (int i = 0; i <= 6; i++) //laver en løkke der sætter et tal ind på de 7 pladser i arrayet.
        //    {
        //        kupon[i] = r.Next(1, 20); //denne sørger for at det er tilfældige tal der bliver sat ind i arrayet.
        //    }
        //    for (int i = 0; i <= 6; i++)
        //    {
        //        Console.WriteLine(kupon[i]);
        //    }
        //    int[] userkupon = new int[7];

        //    for (int i = 0; i <= 6; i++)
        //    {
        //        Console.WriteLine("Type in your numbers for your kupon " + i);
        //        userkupon[i] = int.Parse(Console.ReadLine());

        //    }

        //    for (int i = 0; i <= 6; i++)
        //    {
        //        if (userkupon[i] == kupon[i]) //så sammenligner den alle pladser i begge arrays.
        //        {
        //            Console.WriteLine("Winner");
        //        }
        //        else
        //        {
        //            Console.WriteLine("Looser");
        //        }
        //    }
        //    Console.ReadKey();
        //}

        static public void MOZART()
        {
            int[,] trio = new int[6, 16]
            {
                { 72, 6, 59, 25, 81, 41, 89, 13, 36, 5, 46, 79, 30, 95, 19, 66 },
                { 56, 82, 42, 74, 14, 7, 26, 71, 76, 20, 64, 84, 8, 35, 47, 88 },
                { 75, 39, 54, 1, 65, 43, 15, 80, 9, 34, 93, 48, 69, 58, 90, 21 },
                { 40, 73, 16, 68, 29, 55, 2, 61, 22, 67, 49, 77, 57, 87, 33, 10 },
                { 83, 3, 28, 53, 37, 17, 44, 70, 63, 85, 32, 96, 12, 23, 50, 91 },
                { 18, 45, 62, 38, 4, 27, 52, 94, 11, 92, 24, 86, 51, 60, 78, 31 },
            };
            int[]  arraytrio = new int[16];
            Random r         = new Random();

            for (int i = 0; i < 16; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    int ran = r.Next(0, 6);

                    arraytrio[i] = trio[ran, i];
                    Console.WriteLine(trio[j, i]);
                }
            }
            string[] arraySamlet = new string[32];

            for (int i_files_1 = 0; i_files_1 < 16; i_files_1++)
            {
                arraySamlet[i_files_1 + 15] = @"..\..\SolutionFolder\T" + arraytrio[i_files_1] + ".wav";
            }

            for (int i = 0; i < 16; i++)
            {
                Console.WriteLine(i);
            }



            int[,] minutten = new int[11, 16]
            {
                { 96, 22, 141, 41, 105, 122, 11, 30, 70, 121, 26, 9, 112, 49, 109, 14 },
                { 32, 6, 128, 63, 146, 46, 134, 81, 117, 39, 126, 56, 174, 18, 116, 83 },
                { 69, 95, 158, 13, 153, 55, 110, 24, 66, 139, 15, 132, 73, 58, 145, 79 },
                { 40, 17, 113, 85, 161, 2, 159, 100, 90, 176, 7, 34, 67, 160, 52, 170 },
                { 148, 74, 163, 45, 80, 97, 36, 107, 25, 143, 64, 125, 76, 136, 1, 93 },
                { 104, 157, 27, 167, 154, 68, 118, 91, 138, 71, 150, 29, 101, 162, 23, 151 },
                { 152, 60, 171, 53, 99, 133, 21, 127, 16, 155, 57, 175, 43, 168, 89, 172 },
                { 119, 84, 114, 50, 140, 86, 169, 94, 120, 88, 48, 166, 51, 115, 72, 111 },
                { 98, 142, 42, 156, 75, 129, 62, 23, 65, 77, 19, 82, 137, 38, 149, 8 },
                { 3, 87, 165, 61, 135, 47, 147, 33, 102, 4, 31, 164, 144, 59, 173, 78 },
                { 53, 130, 10, 103, 28, 37, 106, 5, 35, 20, 108, 92, 12, 124, 44, 131 }
            };
            for (int k = 0; k < 11; k++)
            {
                for (int l = 0; l <= 15; l++)
                {
                    //Console.WriteLine(minutten[l, k]);
                }
            }

            for (int i_files_2 = 0; i_files_2 < 16; i_files_2++)
            {
                arraySamlet[i_files_2] = @"..\..\SolutionFolder\M" + arraySamlet[i_files_2] + ".wav";
            }
            for (int i = 0; i < 16; i++)
            {
                Console.WriteLine(i);
            }

            System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
            foreach (string musicelement in arraySamlet)

            {
                sp.SoundLocation = musicelement;

                sp.Load();

                sp.PlaySync();
            }
        }
コード例 #15
0
ファイル: Form1.cs プロジェクト: harry159821/PNG-UI
        private void SAY(string content)
        {
            string[] lines;
            #region decide emotion
            //get current emotion
            Console.WriteLine("EMOTION?");
            emotion = Console.ReadLine();

            //if emotion doesn't exist, set it to empty
            if (emotion == "EMOTION")
            {
                emotion = "";
            }

            //load emotion settings
            try
            {
                lines = System.IO.File.ReadAllLines(Environment.CurrentDirectory + @"\EMOTION.txt");
            }
            catch
            {
                Console.WriteLine(@"ERR(Unable to load the emotion settings. [PNGUI])");
                Console.Out.Flush();
                return;
            }

            //decide emotion
            int numline = 1;
            foreach (string line in lines)
            {
                if (line.Trim() != "" || !line.StartsWith("#")) //allows some formatting
                {
                    string[] separators = { "," };
                    string[] entry = line.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                    try
                    {
                        if (emotion == entry[0])
                        {
                            silent_animation = entry[1];
                            talk_animation = entry[2];
                            File.WriteAllText(Environment.CurrentDirectory + @"\spchGen.bat", "cd %~dp0\n" + entry[3]);
                        }
                    }
                    catch
                    {
                        Console.WriteLine(@"ERR(Unable to parse line " + numline.ToString() + " of the emotion settings. [PNGUI])");
                    }
                }
                numline++;
            }

            #endregion

            #region coordinate animation
            foreach (string part in content.Split(new char[] { '、', ' ', '\t' }))
            {
                if (part.Trim() != "")
                {
                    //Generate speech wav
                    GenSpeech(part);

                        if (!noAnimation)
                        {
                            ANIMATE(talk_animation);
                            using (System.Media.SoundPlayer player = new System.Media.SoundPlayer(Environment.CurrentDirectory + @"\output.wav"))
                            {
                                player.PlaySync();
                            }
                            ANIMATE(silent_animation);
                        }
                        else
                        {
                            using (System.Media.SoundPlayer player = new System.Media.SoundPlayer(Environment.CurrentDirectory + @"\output.wav"))
                            {
                                player.Play();
                            }
                        }

                }

            }

            #endregion
        }
コード例 #16
0
ファイル: Program.cs プロジェクト: SpencerPearson/DungeonApp
        static void Main(string[] args)
        {
            //This is the program that will control the flow of the overall program (the experience of the user). All classes will be build in separate files and referred to in this program to allow us to use instances of the objects.
            Console.Title = "Forest Walker";
            SpeechSynthesizer speech = new SpeechSynthesizer();

            speech.SetOutputToDefaultAudioDevice();
            Console.WriteLine("\n-=-=-= Welcome to ForestWalker =-=-=-\n" +
                              @"                              __
                            .d$$b
                          .' TO$;\
                         /  : TP._;
                        / _.;  :Tb|
                       /   /   ;j$j
                   _.-'       d$$$$
                 .' ..       d$$$$;
                /  / P'      d$$$$P. |\
               / '      .d$$$P' |\^'l
             .'           `T$P^'''''  :
         ._.'      _.'                ;
      `-.- '.-'-' ._.       _.-'.-''
    `.-' _____  ._              .-'
   - (.g$$$$$$$b.              .'
     '' ^^ T$$$P ^)            .(:
          _ / -'  /.'         /:/;
       ._.'-'`-'  ')/         /;/;
 `-.- '..--''   ' /         /  ;
.-' ..--''        -'          :
..--''--.- '         (\      .-(\
  ..--''              `-\(\/;`
    _.                      :
                            ;`-
                           :\
                           ; AWWWWOOOOOO");
            var wolfHowl = new System.Media.SoundPlayer();

            wolfHowl.SoundLocation = @"C:\Users\Student\Documents\Visual Studio 2017\Projects\03_CSF2\CSF2\DungeonApp\Dungeon\Resources\wolfHowl01.wav";
            wolfHowl.PlaySync();
            speech.Speak("Welcome to Forest Walker.");
            Console.WriteLine("\tWhat is your name, Traveler?");
            string playerName = Console.ReadLine();

            Console.Clear();
            //Keep a running total variable for the user's score
            int score          = 0;
            int monstersKilled = 0;

            Console.WriteLine("\tWelcome, {0}. You are about to embark on a spiritual journey through the North American forest.\nAn animal can be chosen to aid you on your journey.", playerName);

            Console.WriteLine();

            //TODO 1. Create a Weapon and a Player
            Weapon dagger = new Weapon(1, 8, "Rusty Dagger", 8, false, "Sword", false, 10, false);
            Weapon bow    = new Weapon(1, 8, "Short Bow", 2, false, "Bow", true, 15, true);
            Weapon club   = new Weapon(5, 8, "Crude Club", 9, false, "Club", false, 0, false);

            Player player = new Player(playerName, 70, 2, 60, 60, Race.Human, bow);
            //Console.WriteLine(sword); - Commented out after testing ToString() return

            //TODO create a loop for finding animal spirit guides (one land one air?)

            //TODO create companions to choose from
            Companion wolf    = new Companion("Lobo", 12, 7, 65, 20, 40, 40, Animal.Wolf, null, "A ferocious wolf with a powerful attack.");
            Companion bear    = new Companion("Ben", 7, 4, 60, 40, 85, 85, Animal.Bear, null, "A great bear with a large health pool.");
            Companion deer    = new Companion("Elliot", 5, 1, 50, 30, 30, 30, Animal.Deer, null, "A swift deer, he can help you escape if things look rough.");
            Companion bison   = new Companion("Strongheart", 6, 2, 60, 60, 100, 100, Animal.Bison, null, "A mighty bison, low attack but his health pool is massive.");
            Companion horse   = new Companion("Beau", 4, 1, 30, 90, 50, 50, Animal.Horse, null, "A sturdy steed, he is fantastic at blocking enemy attacks.");
            Companion mouse   = new Companion("Ralph", 0, 0, 0, 100, 5, 5, Animal.Mouse, null, "A tiny mouse with an uncanny ability to dodge attacks and distract the enemy.");
            Companion raccoon = new Companion("Eddie", 3, 2, 90, 10, 20, 20, Animal.Raccoon, null, "A cheeky raccoon with high accuracy and a low block chance.");
            Companion skunk   = new Companion("Pepe", 4, 2, 55, 40, 20, 20, Animal.Skunk, null, "This skunk is not a powerhouse but he can sometimes stink the enemy into submission.");

            Companion[] companions = { wolf, bear, deer, bison, horse, mouse, raccoon, skunk };
            int         companionChoice;

            repeat   : Console.Write("\tEight animals now appear before you. In the stillness, you sense a purposeful patience in their demeanor.\n Some of these animals you may have caught glimpses or signs of in your journey earlier. Others you have not\n seen or heard until now. They all can aid you in some way, but not all of them will necessarily follow you.\n That is why you must choose your companions wisely.\n\nDo you understand? Y/N:");
            tryAgain : string response = Console.ReadLine().ToUpper();

            if (response == "Y" || response == "YES")
            {
            }
            else if (response == "N" || response == "NO")
            {
                Console.WriteLine("Then I will repeat the instructions. Please read carefully.");
                System.Threading.Thread.Sleep(3000);
                Console.Clear();
                goto repeat;
            }
            else
            {
                Console.Write("Invalid input. Did you understand the instructions? Y/N: ");
                goto tryAgain;
            }
            chooseAnimal : Console.WriteLine("Choose your companion:\n" +
                                             "1) Lobo - wolf\n" +
                                             "2) Ben - bear\n" +
                                             "3) Elliott - deer\n" +
                                             "4) Strongheart - bison\n" +
                                             "5) Beau - horse\n" +
                                             "6) Ralph - mouse\n" +
                                             "7) Eddie - raccoon\n" +
                                             "8) Pepe - skunk\n");

            string userNum = Console.ReadLine();

            if (userNum == "1" || userNum == "2" || userNum == "3" || userNum == "4" || userNum == "5" || userNum == "6" || userNum == "7" || userNum == "8")
            {
                Console.Clear();
                companionChoice = int.Parse(userNum);
                companionChoice--;
                Character companion = companions[companionChoice];
                Console.WriteLine(companion);
                confirmChoice : Console.Write($"\nAre you sure you want to choose {companion.Name} as your companion?\nY/N:");
                string confirm = Console.ReadLine().ToUpper();
                if (confirm == "Y" || confirm == "YES")
                {
                    Console.Clear();
                }
                else if (confirm == "N" || confirm == "NO")
                {
                    Console.Clear();
                    goto chooseAnimal;
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("I need a yes or no answer.");
                    goto confirmChoice;
                }
            }
            else
            {
                Console.WriteLine("Improper input. Please enter a value 1-8 to choose your companion.");
                goto chooseAnimal;
            }

            //TODONE 2. Create a loop for the room and monster
            bool exit = false;

            do
            {
                //TODO 3. Call a new room
                Console.WriteLine(GetRoom());
                //TODONE 4. Create a monster
                Dragon  d1 = new Dragon();
                Dragon  d2 = new Dragon("Toothless", 25, 25, 40, 10, 1, 12, "This is one bad dragon!", true);
                Orc     o1 = new Orc();
                Orc     o2 = new Orc("gruk", 30, 30, 45, 20, 5, 7, "This brutish Orc is uglier than your average Orc, which is saying something!", true);
                Specter s1 = new Specter();
                Specter s2 = new Specter("Bloody Bob", 20, 20, 50, 30, 2, 9, "A bloodthirsty specter darts toward you in a blind rage.", true);

                //Since Rabbit and other child classes are children of monster, all can be placed into an array of Monster objects
                Monster[] monsters = { d1, d1, d2, o1, o1, o1, o1, o1, o2, o2, s1, s1, s2 };

                //Randomly select a monster from the array
                Random  rand         = new Random();
                int     randomNumber = rand.Next(monsters.Length);
                Monster monster      = monsters[randomNumber];
                Console.WriteLine("A monster appears! " + monster.Name);

                //TODO 5. Create a loop for the menu
                bool reload = false;
                do
                {
                    //TODONE 6. Create the menu
                    #region MENU
                    Console.WriteLine("\n\nPlease choose an Action:\n" +
                                      "A) Attack\n" +
                                      "R) Run Away\n" +
                                      "P) Player Info\n" +
                                      "M) Monster Info\n" +
                                      "C) Companion Info\n" +
                                      "X) Exit\n\n" +
                                      $"Score: {score}\n\n");
                    #endregion
                    //TODONE 7. Get User Choice
                    #region UserChoice
                    ConsoleKey userChoice = Console.ReadKey(true).Key;
                    #endregion

                    //TODONE 8. Clear the console after we get input from the user
                    Console.Clear();

                    //TODO need to make program work without statement below
                    Companion companion = companions[companionChoice];

                    //TODO 9. Build out the switch for userChoice
                    #region Game Experience - Switch
                    switch (userChoice)
                    {
                    case ConsoleKey.A:
                        Console.WriteLine("Attack\n");
                        //TODO 10. Build attack logic and place here
                        Combat.DoBattle(player, companion, monster);
                        if (monster.Life <= 0)
                        {
                            //it's dead - you could put some logic here to have player get items, get life back , or something similar due to defeating the monster.
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("\nYou killed {0}! The spirit you freed from the monster restores some of your health.\n", monster.Name);
                            Console.ResetColor();
                            player.Life += monster.MaxLife / 4;
                            score       += monster.MaxLife - (player.MaxLife - player.Life);
                            monstersKilled++;
                            reload = true;
                            //get a new room and monster
                            if (monstersKilled < 10)
                            {
                            }
                            else
                            {
                                Console.WriteLine($"" +
                                                  $"\tAs you deal the final blow to {monster.Name}, {companion.Name} seems to leap in\n triumph at your accomplishment. The monsters have been vanquished, and their tortured\n souls are now free. As you meet {companion.Name}'s eyes, a great sense of confidence\n and strength rises up within you. You know you made the right choice, and that the\n {companion.Animal} is truly your animal guide." +
                                                  $"\n\n\tYou snap awake in your bed, and glance at the alarm clock on the nightstand.\n It's 3:33 a.m. The dream of the forest was so vivid, so incredibly real. You close your eyes, and still can clearly see the approving gaze\n of {companion.Name}. You\n realize that image will be burned into your memory, and any time you need help you'll\n be able to call upon the spirit of the {companion.Animal} to guide you in the waking world. You roll over and drift back to sleep, and as you drift away a calming sense\n of security washes over you. All is well.\n\n" +
                                                  $"Final score: {score}\n" +
                                                  $"Monsters killed: {monstersKilled}");
                                exit   = true;
                                reload = false;
                            }
                        }
                        break;

                    case ConsoleKey.R:
                        Console.WriteLine("Run for your life!");
                        //TODO 11. Build run away logic
                        Console.WriteLine($"{monster.Name} attacks you as you run!\n");
                        Combat.DoAttack(monster, player);
                        //load a new room and monster
                        reload = true;
                        break;

                    case ConsoleKey.P:
                        Console.WriteLine("Player Info");
                        //TODONE 12. Add Player Info
                        Console.WriteLine(player);
                        break;

                    case ConsoleKey.M:
                        Console.WriteLine("Monster Info");
                        //TODONE 13. Add Monster Info
                        Console.WriteLine(monster);
                        break;

                    case ConsoleKey.C:
                        Console.WriteLine("Companion Info");
                        Console.WriteLine(companion);
                        break;

                    case ConsoleKey.X:
                    case ConsoleKey.E:
                        Console.WriteLine("The forest can break even the most battle-hardened. Strengthen your resolve before entering these woods again.");
                        exit = true;
                        break;

                    default:
                        Console.WriteLine("That input was not recognized. Please choose a valid option.\n");
                        break;
                    }
                    #endregion
                    if (player.Life <= 0)
                    {
                        Console.WriteLine($"" +
                                          $"\tAs the light fades, you turn to lock eyes with {companion.Name}. He looks sad,\n but stoic as your life fades away. You both gave your best. Perhaps the\n {companion.Animal} was not your proper animal guide." +
                                          $"\n\n\tYou snap awake in your bed, and glance at the alarm clock on the nightstand.\n It's 3:33 a.m. The dream of the forest was so vivid, so incredibly real. You lift your\n shirt and check your body for the wounds that just claimed you, just to make sure\n you aren't still bleeding out. You're fine, of course. Even still, the image of{monster.Name}\n hovering over you, the look in {companion.Name}'s eyes as you drew\n your last breath... You can feel the image is going to stick with you for quite some\n time." +
                                          $"\n\nMaybe you'll be able to settle back down to sleep, and one day again become the Forest Walker.\n\n" +
                                          $"Final score: {score}\n" +
                                          $"Monsters killed: {monstersKilled}");
                        exit = true;
                    }

                    //TODO 14. Handle Player Life
                } while (!reload && !exit);
            } while (!exit);//while exit is NOT TRUE keep in the loop
        }//end Main()
コード例 #17
0
ファイル: Program.cs プロジェクト: red-the-random-dev/DotVox
        public static void Main(string[] args)
        {
            InitializeSettings();
            if (args[0].Length == 0)
            {
                Environment.Exit(-1);
            }
            FileStream   fs = new FileStream(args[0], FileMode.Open, FileAccess.Read);
            StreamReader sr = new StreamReader(fs);

            List <String[]> Commands = new List <string[]>();

            while (!sr.EndOfStream)
            {
                Commands.Add(sr.ReadLine().Split());
            }
            sr.Close();
            fs.Close();
            foreach (String[] x in Commands)
            {
                Boolean DoFeedback  = (ComposerSettings["feedback"] == 1);
                Boolean DoVisualize = (ComposerSettings["visualize"] == 1);
                if (x.Length == 0)
                {
                    if (OnAir)
                    {
                        sqt.SkipAll();
                    }
                    continue;
                }

                switch (x[0])
                {
                case "#cfg":
                {
                    List <String[]> cfgs = new List <string[]>();

                    for (int c = 1; c < x.Length; c++)
                    {
                        cfgs.Add(x[c].Split(':'));
                    }
                    foreach (String[] p in cfgs)
                    {
                        ComposerSettings[p[0]] = UInt32.Parse(p[1]);
                    }
                    break;
                }

                case "#instruments":
                {
                    List <String[]> cfgs = new List <string[]>();

                    for (int c = 1; c < x.Length; c++)
                    {
                        cfgs.Add(x[c].Split(':'));
                    }
                    foreach (String[] p in cfgs)
                    {
                        String[] defSettings = { null, null, "24576", "1", "1", "1", "1" };

                        for (int i = 0; i < Math.Min(p.Length, defSettings.Length); i++)
                        {
                            defSettings[i] = p[i];
                        }

                        InstrumentConfig16 ic16 = new InstrumentConfig16
                                                  (
                            Instruments16.GetTimedWave,
                            Int32.Parse(defSettings[1]),
                            Int16.Parse(defSettings[2]),
                            ComposerSettings["samplerate"],
                            (defSettings[3] == "1"),
                            Double.Parse(defSettings[4]),
                            Double.Parse(defSettings[5]),
                            (defSettings[6] == "1")
                                                  );
                        if (DoFeedback)
                        {
                            Console.WriteLine("Instrument definition: Tag: {0}, IID: {1}, Volume: {2}, Fadeout: {3}, Fadeout strength: {4}, Start position: {5}, Keep start volume: {6}", defSettings[0], ic16.Number, ic16.Amplitude, ic16.DoFadeout, ic16.FadeoutStrength, ic16.FadeoutPosition, ic16.KeepVolumeBeforeFadeout);
                        }
                        InstrumentSet.Add(defSettings[0], ic16);
                    }
                    break;
                }

                case "#saveat":
                {
                    SavePath = x[1];
                    break;
                }

                case "#begin":
                {
                    if (DoFeedback)
                    {
                        Console.WriteLine("Starting file parsing...");
                    }
                    OnAir = true;
                    sqt   = new SequenceTracer16(Keys, InstrumentSet, (1.0 / ComposerSettings["tactrate"]));
                    break;
                }

                case "#end":
                {
                    if (DoFeedback)
                    {
                        Console.WriteLine("Finished parsing, saving...");
                    }
                    OnAir = false;
                    sq16  = new Sequencer16(1, ComposerSettings["samplerate"]);
                    sqt.Export(sq16);
                    break;
                }

                case "#play":
                {
                    if (DoFeedback)
                    {
                        Console.WriteLine("Playing . . .");
                    }
                    if (sq16 == null)
                    {
                        break;
                    }
                    System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
                    sp.Stream = sq16.SnapshotStream;

                    sp.Load();
                    sp.PlaySync();
                    break;
                }

                case "#save":
                {
                    FileStream fout = new FileStream(SavePath, FileMode.Create, FileAccess.Write);
                    WaveFormatter16.WriteSequenceToFile(sq16, fout);
                    fout.Close();
                    break;
                }

                default:
                {
                    if (!OnAir)
                    {
                        break;
                    }
                    if (x.Length == 0)
                    {
                        sqt.SkipAll();
                        break;
                    }
                    foreach (String b in x)
                    {
                        Boolean  StartAnew = false;
                        String[] p         = b.Split(':');
                        if (p.Length < 2)
                        {
                            sqt.SkipAll();
                            break;
                        }
                        if (p.Length == 3)
                        {
                            if (p[2] == "x")
                            {
                                StartAnew = true;
                            }
                        }
                        Int32 key = Int32.Parse(p[1]);
                        if (StartAnew)
                        {
                            sqt.PushAnew(key, p[0]);
                        }
                        else
                        {
                            sqt.Push(key, p[0]);
                        }

                        if (DoVisualize)
                        {
                            Console.CursorLeft = key;
                            Console.Write(p[0][0]);
                        }
                    }
                    sqt.Snap();
                    if (DoVisualize)
                    {
                        Console.WriteLine();
                    }
                    break;
                }
                }
            }

            if (ComposerSettings["pauseatend"] == 1)
            {
                Console.WriteLine("Press any key to continue . . .");
                Console.ReadKey(true);
            }
        }
コード例 #18
0
ファイル: Program.cs プロジェクト: KavTV/SkoleProgrammering
        static void Main(string[] args)
        {
            //gør det nemmere at ændre lokation
            string fileLocation = @"C:\Users\kasp609g\Downloads\Wave\Wave";

            Random random = new Random();

            System.Media.SoundPlayer sp = new System.Media.SoundPlayer();


            string[] minuetFiles = new string[176];
            string[] trioFiles   = new string[96];
            //Har spildt alt min tid på at skrive de to tabeller.
            int[,] minuetTable =
            {
                {  96,  32,  69,  40, 148, 104, 152, 119,  98,   3,  54 }, //1
                {  22,   6,  95,  17,  74, 157,  60,  84, 142,  87, 130 }, //2
                { 141, 128, 158, 113, 163,  27, 171, 114,  42, 165,  10 }, //3
                {  41,  63,  13,  85,  45, 167,  53,  50, 156,  61, 103 }, //4
                { 105, 146, 153, 161,  80, 154,  99, 140,  75, 135,  28 }, //5
                { 122,  46,  55,   2,  97,  68, 133,  86, 129,  47,  37 }, //6
                {  11, 134, 110, 159,  36, 118,  21, 169,  62, 147, 106 }, //7
                {  30,  81,  24, 100, 107,  91, 127,  94, 123,  33,   5 }, //8
                {  70, 117,  66,  90,  25, 138,  16, 120,  65, 102,  35 }, //9
                { 121,  39, 139, 176, 143,  71, 155,  88,  77,   4,  20 }, //10
                {  26, 126,  15,   7,  64, 150,  57,  48,  19,  31, 108 }, //11
                {   9,  56, 132,  34, 125,  29, 175, 166,  82, 164,  92 }, //12
                { 112, 174,  73,  67,  76, 101,  43,  51, 137, 144,  12 }, //13
                {  49,  18,  58, 160, 136, 162, 168, 115,  38,  59, 124 }, //14
                { 109, 116, 145,  52,   1,  23,  89,  72, 149, 173,  44 }, //15
                {  14,  83,  79, 170,  93, 151, 172, 111,   8,  78, 131 }//16
            };

            int[,] trioTable =
            {
                { 72, 56, 75, 40, 83, 18 }, //17
                {  6, 82, 39, 73,  3, 45 }, //18
                { 59, 42, 51, 16, 28, 62 }, //19
                { 25, 74,  1, 68, 53, 38 }, //20
                { 81, 14, 65, 29, 37,  4 }, //21
                { 41,  7, 43, 55, 17, 27 }, //22
                { 89, 26, 15,  2, 44, 52 }, //23
                { 13, 71, 80, 61, 70, 94 }, //24
                { 36, 76,  9, 22, 63, 11 }, //25
                {  5, 20, 34, 67, 85, 92 }, //26
                { 46, 64, 93, 49, 32, 24 }, //27
                { 79, 84, 48, 77, 96, 86 }, //28
                { 30,  8, 69, 57, 15, 51 }, //29
                { 95, 35, 58, 87, 23, 60 }, //30
                { 19, 47, 90, 33, 50, 78 }, //31
                { 66, 88, 21, 10, 91, 31 }//32
            };
            //lav musik til minuet
            for (int i = 0; i < 16; i++)
            {
                //lav tilfældige tal
                int dice1 = random.Next(1, 7);
                int dice2 = random.Next(1, 7);
                //Lav lokation af filerne og afspiller musik
                sp.SoundLocation = fileLocation + @"\M" + minuetTable[i, (dice1 + dice2 - 2)] + ".wav";
                sp.Load();
                sp.PlaySync();
            }
            for (int i = 0; i < 16; i++)
            {
                int dice1 = random.Next(1, 7);
                int dice2 = random.Next(1, 7);

                sp.SoundLocation = fileLocation + @"\T" + trioTable[i, (dice1 - 1)] + ".wav";
                sp.Load();
                sp.PlaySync();
            }
        }
コード例 #19
0
        private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            // Creamos la fuente y la brocha para el texto
            Font       fuente         = new Font("Arial", 16);
            SolidBrush brocha         = new SolidBrush(Color.White);
            SolidBrush brochaAmarilla = new SolidBrush(Color.Yellow);
            SolidBrush brochaNegra    = new SolidBrush(Color.Black);
            SolidBrush brochaRoja     = new SolidBrush(Color.Red);
            SolidBrush brochaNaranja  = new SolidBrush(Color.Orange);

            MiNinja.activo = true;
            MiNinja.img    = new Bitmap(Properties.Resources.cesta);

            // Dibujamos las frutas
            for (int n = 0; n < 10; n++)
            {
                if (ListaObjetos[n].activo == true) //de estar activo dibuja la fruta
                {
                    e.Graphics.DrawImage(ListaObjetos[n].img, ListaObjetos[n].x - 4, ListaObjetos[n].y - 4, 20, 20);
                }
                else //de lo contrario dibuja un arbol seco en lugar de la fruta
                {
                    e.Graphics.DrawImage(Properties.Resources.dry_tree, ListaObjetos[n].x - 4, ListaObjetos[n].y - 4, 20, 20);
                }
            }

            // Dibujamos la bateria
            e.Graphics.DrawImage(MiBateria[0].img, MiBateria[0].x - 4, MiBateria[0].y - 4, 20, 20);



            // Indicamos la energia del ninja
            e.Graphics.DrawImage(Properties.Resources.energy, this.Width - 130, 10, 20, 20);
            if (maquina.getEnergia <= 200) //barra de energía roja si <= 200
            {
                e.Graphics.DrawRectangle(Pens.Red, this.Width - 110, 12, 80, 10);
                e.Graphics.FillRectangle(brochaRoja, this.Width - 110, 12, maquina.getEnergia / 10, 10);
            }
            else if (maquina.getEnergia <= 400) //barra de energía anaranjada si <= 400
            {
                e.Graphics.DrawRectangle(Pens.Orange, this.Width - 110, 12, 80, 10);
                e.Graphics.FillRectangle(brochaNaranja, this.Width - 110, 12, maquina.getEnergia / 10, 10);
            }
            else //barra de energía amarilla si ninguna de las anteriores se cumplen
            {
                e.Graphics.DrawRectangle(Pens.Yellow, this.Width - 110, 12, 80, 10);
                e.Graphics.FillRectangle(brochaAmarilla, this.Width - 110, 12, maquina.getEnergia / 10, 10);
            }

            e.Graphics.DrawImage(MiNinja.img, maquina.CoordX - 4, maquina.CoordY - 4); //Dibujamos al ninja

            switch (maquina.EstadoM)
            {
            case (int)CMaquina.estados.MUERTO:
                //se dibuja rectangulo negro
                e.Graphics.FillRectangle(brochaNegra, 0, 0, this.Width, this.Height);
                //se escribe "you died"
                e.Graphics.DrawString("YOU DIED", new Font("Times New Roman", 30), new SolidBrush(Color.Red),
                                      this.Width / 2 - 100, this.Height / 2 - 60);
                // Sonamos un beep de la computadora
                System.Media.SoundPlayer gameover = new System.Media.SoundPlayer(Properties.Resources.died);
                gameover.Play();
                //se le indica a la máquina que el juego ha terminado
                gameState = false;
                break;

            case (int)CMaquina.estados.GANADOR:
                //se escribe estado actual
                e.Graphics.DrawString("Estado: Ganador", fuente, brocha, 10, 10);
                // sonamos beep de victoria
                System.Media.SoundPlayer winner = new System.Media.SoundPlayer(Properties.Resources.victory);
                winner.Play();
                //se le indica a la máquina que el juego ha terminado
                gameState = false;
                break;

            case (int)CMaquina.estados.BUSCANDO:
                //se escribe estado actual
                e.Graphics.DrawString("Estado: Buscando", fuente, brocha, 10, 10);
                play_found = true;
                break;

            case (int)CMaquina.estados.ENCONTRO:
                //se escribe estado actual
                e.Graphics.DrawString("Estado: Encontró", fuente, brocha, 10, 10);
                if (play_found)
                {
                    System.Media.SoundPlayer found = new System.Media.SoundPlayer(Properties.Resources.found);
                    found.PlaySync();
                    play_found = false;
                }
                break;

            case (int)CMaquina.estados.POCABATERIA:
                //se escribe estado actual
                e.Graphics.DrawString("Estado: Poca energía", fuente, brocha, 10, 10);
                if (play_low_battery)
                {
                    System.Media.SoundPlayer low_battery = new System.Media.SoundPlayer(Properties.Resources.low_battery);
                    low_battery.PlaySync();
                    play_low_battery = false;
                }
                break;

            case (int)CMaquina.estados.RECARGANDO:
                //se escribe estado actual
                e.Graphics.DrawString("Estado: Recargando", fuente, brocha, 10, 10);
                System.Media.SoundPlayer charging = new System.Media.SoundPlayer(Properties.Resources.charging);
                charging.PlaySync();
                play_low_battery = true;
                break;
            }
        }
コード例 #20
0
        //public void Play(bool loop = false)
        //{
        //    var playCount = loop ? Songs.Count : 1;
        //    if (_isLocked)
        //    {
        //        return;
        //    }
        //    _isPlaying = true;
        //    for (int i = 0; i < playCount; i++)
        //    {
        //        Console.WriteLine($"Player is playing: {Songs[i].Name}, duration: {Songs[i].Duration}");
        //        System.Threading.Thread.Sleep(1000);
        //    }
        //}

        public void Play(bool loop = false)
        {
            if (_isLocked)
            {
                return;
            }
            ISkin.NewScreen();
            var playCount = loop ? Songs.Count : 1;

            for (int i = 0; i < playCount; i++)
            {
                if (Songs[i].Like.GetValueOrDefault(false))
                {
                    //Console.ForegroundColor = ConsoleColor.Green;
                    //Console.WriteLine($"Player is playing liked songs: {Songs[i].Name}, duration: {Songs[i].Duration}");
                    //Console.ResetColor();
                    ISkin.Render($"Player is playing liked songs: {Songs[i].Name}, duration: {Songs[i].Duration}");

                    foreach (var song in Songs)
                    {
                        PlayingSong = song;
                        SongStartedEvent?.Invoke(Songs, song, _isLocked, _volume);

                        using (System.Media.SoundPlayer player = new System.Media.SoundPlayer())
                        {
                            player.SoundLocation = PlayingSong.Path;
                            player.PlaySync();
                        }
                    }
                }
                //  else if (Songs[i].Like.HasValue ? !Songs[i].Like.Value : false)
                else if (Songs[i].Like.HasValue && !Songs[i].Like.Value)
                {
                    //Console.ForegroundColor = ConsoleColor.Red;
                    //Console.WriteLine($"Player is playing liked songs: {Songs[i].Name}, duration: {Songs[i].Duration}");
                    //Console.ResetColor();
                    ISkin.Render($"Player is playing liked songs: {Songs[i].Name}, duration: {Songs[i].Duration}");
                    foreach (var song in Songs)
                    {
                        PlayingSong = song;
                        SongStartedEvent?.Invoke(Songs, song, _isLocked, _volume);

                        using (System.Media.SoundPlayer player = new System.Media.SoundPlayer())
                        {
                            player.SoundLocation = PlayingSong.Path;
                            player.PlaySync();
                        }
                    }
                }
                else
                {
                    //Console.WriteLine($"Player is playing liked songs: {Songs[i].Name}, duration: {Songs[i].Duration}");
                    ISkin.Render($"Player is playing liked songs: {Songs[i].Name}, duration: {Songs[i].Duration}");
                    System.Threading.Thread.Sleep(1000);
                    foreach (var song in Songs)
                    {
                        PlayingSong = song;
                        SongStartedEvent?.Invoke(Songs, song, _isLocked, _volume);

                        using (System.Media.SoundPlayer player = new System.Media.SoundPlayer())
                        {
                            player.SoundLocation = PlayingSong.Path;
                            player.PlaySync();
                        }
                    }
                }
                //Console.WriteLine($"Player is playing: {Songs[i].Name}, duration: {Songs[i].Duration}");
                //Skin.Render($"Player is playing liked songs: {Songs[i].Name}, duration: {Songs[i].Duration}");
                //System.Threading.Thread.Sleep(1000);
            }
        }
コード例 #21
0
ファイル: Form1.cs プロジェクト: Ikari2015/Live2D
        private void SAY(int id, string content)
        {
            string[] lines;
            #region decide emotion
            //get current emotion
            Console.WriteLine("EMOTION?");
            emotion = Console.ReadLine();

            //if emotion doesn't exist, set it to empty
            if (emotion == "EMOTION")
            {
                emotion = "";
            }

            //load emotion settings
            try
            {
                lines = System.IO.File.ReadAllLines(Environment.CurrentDirectory + @"\EMOTION.txt");
            }
            catch
            {
                Console.WriteLine(@"ERR(Unable to load the emotion settings. [PNGUI])");
                Console.Out.Flush();
                return;
            }

            //decide emotion
            int numline = 1;
            foreach (string line in lines)
            {
                if (line.Trim() != "" || !line.StartsWith("#")) //allows some formatting
                {
                    string[] separators = { "," };
                    string[] entry = line.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                    try
                    {
                        if (emotion == entry[0])
                        {
                            File.WriteAllText(Environment.CurrentDirectory + @"\spchGen.bat", "cd %~dp0\n" + entry[1]);
                        }
                    }
                    catch
                    {
                        Console.WriteLine(@"ERR(Unable to parse line " + numline.ToString() + " of the emotion settings. [PNGUI])");
                    }
                }
                numline++;
            }

            #endregion

            int length;
            #region coordinate animation
            foreach (string part in content.Split(new char[] { '、', ' ', '\t' }))
            {
                if (part.Trim() != "")
                {

                    //Generate speech wav
                    length = GenSpeech(part);

                    if (length == 0) { return; }

                    //float[] amps = AmplitudesFromFile(Environment.CurrentDirectory + @"\res\sound\speech.wav");

                    if (!noAnimation)
                    {
                        Console.WriteLine(@"UI_PlaySound(res\sound\speech.wav," + id + ")");
                        System.Threading.Thread.Sleep(length);
                    }
                    else
                    {
                        using (System.Media.SoundPlayer player = new System.Media.SoundPlayer(Environment.CurrentDirectory + @"\res\sound\speech.wav"))
                        {
                            player.PlaySync();
                        }
                    }
                    Console.WriteLine("UI_SetMouthOpen(0," + id + ")");

                }

            }

            #endregion
        }
コード例 #22
0
        static void Main(string[] args)
        {
            NeutrinoController nc = new NeutrinoController();

            string outputMusicXML = "output.musicxml";

            try
            {
                Parser.Default.ParseArguments <Options>(args)
                .WithParsed(opt =>
                {
                    nc.FormantShift = opt.FormantShift;
                    nc.PitchShift   = (float)Math.Pow(2, opt.PitchShift / 12f);
                    nc.Model        = opt.Model;
                    if (opt.NumberOfThread != -1)
                    {
                        nc.NumberOfThreads = opt.NumberOfThread;
                    }

                    // set MML
                    string mml = "";
                    if (opt.Remaining != null && opt.Remaining.ToArray().Length > 0)
                    {
                        mml = string.Join(" ", opt.Remaining.ToArray());
                    }
                    if (opt.InputFileName != null)
                    {
                        mml = File.ReadAllText(opt.InputFileName);
                        if (string.IsNullOrEmpty(opt.OutputFileName))
                        {
                            opt.OutputFileName = Path.ChangeExtension(opt.InputFileName, ".wav");
                        }
                    }
                    nc.OutputFileName = string.IsNullOrEmpty(opt.OutputFileName) ? "output.wav" : opt.OutputFileName;
                    if (string.IsNullOrEmpty(mml))
                    {
                        Console.WriteLine("ヘルプを表示するには --help を入力してください");
                        return;
                    }

                    IElement[] elements = null;
                    try
                    {
                        elements = nc.Parse(mml, opt.Reverse);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        return;
                    }

                    if (opt.KeyShift != 0)
                    {
                        elements = nc.ChangeKey(opt.KeyShift, elements);
                    }

                    XElement xml = null;
                    try
                    {
                        xml = nc.ConvertToMusicXML(elements);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        return;
                    }

                    string musicXmlFile = "";
                    try
                    {
                        musicXmlFile = Path.GetFullPath(outputMusicXML);
                        xml.Save(musicXmlFile);
                    }
                    catch (IOException ex)
                    {
                        Console.WriteLine(ex.Message);
                        return;
                    }

                    string outputWav = nc.RunNeutrino(musicXmlFile);

                    // Play wave file
                    if (!opt.Silent)
                    {
                        Console.WriteLine($"Playing...");
                        System.Media.SoundPlayer player = new System.Media.SoundPlayer(outputWav);
                        player.PlaySync();
                    }
                });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return;
            }
        }
コード例 #23
0
        private void PlaySound()
        {
            string wavPath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), WavFileUriPath);
            Uri uri = new Uri(wavPath);
            System.Media.SoundPlayer player = new System.Media.SoundPlayer(WavFileUriPath);
            player.PlaySync();

            this.Dispatcher.Invoke((Action)(() =>
            {
                recordGrid.Visibility = System.Windows.Visibility.Visible;
                recordingdGrid.Visibility = System.Windows.Visibility.Hidden;

                DisplayAnalysis();
            }));
        }
コード例 #24
0
        private void getData()
        {
            try
            {
                myIndicator = JsonSerializer._download_serialized_json_data <indicator>(indicatorsurl);
                myState     = JsonSerializer._download_serialized_json_data <state>(statesurl);



                if (myState.valid == "true")
                {
                    decimal G     = Convert.ToDecimal(myState.Ny, culture);
                    decimal AoA   = Convert.ToDecimal(myState.AoA, culture);
                    decimal Alt   = Convert.ToDecimal(myIndicator.altitude_hour, culture);
                    int     gear  = Convert.ToInt32(myState.gear);
                    int     IAS   = Convert.ToInt32(myState.IAS);
                    int     flaps = Convert.ToInt32(myState.flaps);
                    label.Content = myIndicator.type;

                    if (cbx_g.IsChecked == true && G > User.Default.GForce)
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.breaths);
                        myPlayer.PlaySync();
                    }



                    if (AoA > User.Default.AoA && myIndicator.gears_lamp == "1" && cbx_a.IsChecked == true)
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.carflt_stallhorn02);
                        myPlayer.PlaySync();
                    }
                    if (User.Default.EnableGear == true && gear == 100 && IAS > User.Default.GearUp)
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.gearwarn);
                        myPlayer.PlaySync();
                    }

                    if (User.Default.EnableGear == true && gear == 0 && IAS < User.Default.GearDown && Alt < 500 && flaps > 20)
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.gearwarn);
                        myPlayer.PlaySync();
                    }
                }
                else
                {
                    dispatcherTimer1.Stop();
                    dispatcherTimer2.Start();
                }
            }
            catch (Exception ex)
            {
                tbx_msgs.Text = ex.Message;
                dispatcherTimer1.Stop();
                dispatcherTimer2.Start();
            }
        }
コード例 #25
0
        void MakeSignal()
        {
            byte[] MsgS = Encoding.UTF8.GetBytes(m_Message);
            byte[] BitStream = Encode(MsgS);
            double[] Gaussian = MakeGaussian(1 / m_Bitrate);
            double[] DigitalSignal = MakeDigitalSignal(m_Bitrate, BitStream);
            double[] AmpSignal1 = MakeAmpSignal(m_Bitrate, DigitalSignal.Length);
            double[] AmpSignal2 = Normalize(Convolution2(Gaussian, AmpSignal1));
            double[] DigitalSignal3 = Normalize(Convolution2(Gaussian, DigitalSignal));
            double[] FModSignal = FModulation(DigitalSignal3, m_SineFreq1, m_SineFreq2);
            double[] AFModSignal = AModulation(FModSignal, AmpSignal2);
            double[] Silence = MakeSilence(0.1);
            double[] Result = Silence.Concat(AFModSignal).Concat(Silence).ToArray();

            /*
            SaveWav("1.wav", SignalDtoS(Gaussian));
            SaveWav("2.wav", SignalDtoS(DigitalSignal));
            SaveWav("3.wav", SignalDtoS(AmpSignal1));
            SaveWav("4.wav", SignalDtoS(AmpSignal2));
            SaveWav("5.wav", SignalDtoS(DigitalSignal3));
            SaveWav("6.wav", SignalDtoS(FModSignal));
            SaveWav("7.wav", SignalDtoS(AFModSignal));
            */

            string outName = string.Format("TS_{0}_{1}_{2}.wav",
                m_SineFreq1, m_SineFreq2, m_Bitrate);
            SaveWav(outName, SignalDtoS(Result));

            for (int i = 0; i < 3; i++)
            {
                SendButton.Dispatcher.Invoke(
                    DispatcherPriority.Normal,
                    new Action(() => { SendButton.Content = (3 - i); }));
                System.Threading.Thread.Sleep(500);
            }
            SendButton.Dispatcher.Invoke(
                DispatcherPriority.Normal,
                new Action(() => { SendButton.Content = "Play!"; }));

            var Player = new System.Media.SoundPlayer();
            Player.SoundLocation = outName;
            Player.PlaySync();

            File.Delete(outName);

            Freq1Slider.Dispatcher.Invoke(
                DispatcherPriority.Normal,
                new Action(() => { Freq1Slider.IsEnabled = true; }));
            Freq2Slider.Dispatcher.Invoke(
                DispatcherPriority.Normal,
                new Action(() => { Freq2Slider.IsEnabled = true; }));
            BitrateSlider.Dispatcher.Invoke(
                DispatcherPriority.Normal,
                new Action(() => { BitrateSlider.IsEnabled = true; }));
            MessageTextBox.Dispatcher.Invoke(
                DispatcherPriority.Normal,
                new Action(() => { MessageTextBox.IsEnabled = true; }));
            SendButton.Dispatcher.Invoke(
                DispatcherPriority.Normal,
                new Action(() => { SendButton.IsEnabled = true; }));

            SendButton.Dispatcher.Invoke(
                DispatcherPriority.Normal,
                new Action(() => { SendButton.Content = "Send"; }));
        }
コード例 #26
0
ファイル: WinApi.cs プロジェクト: broliver/LabLauncher
 /// <summary>
 /// Plays a wav file
 /// </summary>
 /// <param name="path">Path to wav file</param>
 public void WaveSound(string path)
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer();
     if (File.Exists(path))
     {
         player.SoundLocation = path;
         player.PlaySync();
     }
 }
コード例 #27
0
ファイル: OpenCam.cs プロジェクト: riz-khan/facial-attendance
        //-----------------------------------Frame Procedure End----------------------------------------------

        //---------------------------------------Mark attendance----------------------------------------------

        public void markAttendance(int emp_id)
        {
            try
            {
                string soundLocation            = Application.StartupPath + "/audio/thankyou.wav";
                System.Media.SoundPlayer player = new System.Media.SoundPlayer(soundLocation);
                player.PlaySync();
                myconnection.ConnectionString = Properties.Settings.Default.ConnectionString;
                myconnection.Open();

                //check if time is before 12 or after 12 and enter data accordingly
                TimeSpan tod      = DateTime.Now.TimeOfDay;
                int      nowMins  = (int)tod.TotalMinutes;
                int      lateMins = 12 * 60; // 12:00 pm
                Console.WriteLine("totalmins: " + tod.TotalMinutes);

                string query = "";

                if (nowMins >= lateMins)
                {
                    Console.WriteLine("after 12");
                    query = "insert into EmployeeLog(Userid,VerifyType,Atime,Timetype)Values ('" + emp_id + "','F',Sysdate,'O')";
                }
                else
                {
                    Console.WriteLine("before 12");
                    query = "insert into EmployeeLog(Userid,VerifyType,Atime,Timetype)Values ('" + emp_id + "','F',Sysdate,'I')";
                }
                OracleCommand cmd1 = new OracleCommand(query, myconnection);
                cmd1.ExecuteNonQuery();

                string path = Application.StartupPath + "/log/(" + DateTime.Now.ToString("dd-MM-yyyy") + ").txt";
                if (!File.Exists(path))
                {
                    File.Create(path).Dispose();
                    using (var tw = new StreamWriter(path, true))
                    {
                        tw.WriteLine(emp_id + ", F, " + DateTime.Now);
                    }
                }
                else if (File.Exists(path))
                {
                    using (var tw = new StreamWriter(path, true))
                    {
                        tw.WriteLine(emp_id + " " + DateTime.Now);
                    }
                }

                // Autoclose messagebox (1 second)
                var w = new Form()
                {
                    Size = new Size(0, 0)
                };
                Task.Delay(TimeSpan.FromSeconds(1))
                .ContinueWith((t) => w.Close(), TaskScheduler.FromCurrentSynchronizationContext());
                MessageBox.Show(w, "ATTENDANCE MARKED FOR (" + emp_id + ")", "ATTENDANCE MARKED");

                //sleep attendance process (1 second)
                System.Threading.Thread.Sleep(1000);
                myconnection.Close();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.ToString());
            }
            finally{
                myconnection.Close();
            }
        }
コード例 #28
0
        private void IsEngineFailed()
        {
            if (Throttle1 > 75 && Thrust1 < ThrustFailed)
            {
                ++TRCount;
                if (TRCount < 50)
                {
                    ;
                }
                else
                {
                    System.Media.SoundPlayer myPlayer;
                    myPlayer = new System.Media.SoundPlayer(Properties.Resources.engine1fail);
                    myPlayer.PlaySync();
                }
            }
            if (Throttle2 > 75 && Thrust2 < ThrustFailed)
            {
                ++TRCount;
                if (TRCount < 50)
                {
                    ;
                }
                else
                {
                    System.Media.SoundPlayer myPlayer;
                    myPlayer = new System.Media.SoundPlayer(Properties.Resources.engine2fail);
                    myPlayer.PlaySync();
                }
            }

            /*if (Throttle1 > 90 && Thrust1 < ThrustReduced)
             * {
             ++TRCount;
             *  if (TRCount < 50 || TRCount > 51)
             *  {
             *      ;
             *  }
             *  else
             *  {
             *
             *      System.Media.SoundPlayer myPlayer;
             *      myPlayer = new System.Media.SoundPlayer(Properties.Resources.engine1degraded);
             *      myPlayer.PlaySync();
             *  }
             * }
             * if (Throttle2 > 90 && Thrust2 < ThrustReduced)
             * {
             ++TRCount;
             *  if (TRCount < 50 || TRCount > 51)
             *  {
             *      ;
             *  }
             *  else
             *  {
             *      System.Media.SoundPlayer myPlayer;
             *      myPlayer = new System.Media.SoundPlayer(Properties.Resources.engine2degraded);
             *      myPlayer.PlaySync();
             *  }
             * }*/
            if (TRCount > 1 && Throttle1 < 50 && Throttle2 < 50)
            {
                TRCount = 0;
            }
        }
コード例 #29
0
 /// <summary>
 /// plays a click sound to enhance realism
 /// </summary>
 public void ButtonClick()
 {
     System.Media.SoundPlayer click = new System.Media.SoundPlayer(@"Sound\click_x.wav");
     click.PlaySync();
 }
コード例 #30
0
 private void FlapsPO()
 {
     if (flaps > 0 && flaps <= 20)
     {
         if (IAS > (Vfc - 20))
         {
             System.Media.SoundPlayer myPlayer;
             myPlayer = new System.Media.SoundPlayer(Properties.Resources.checkflaps);
             myPlayer.PlaySync();
         }
     }
     else if (flaps > 20 && flaps <= 33)
     {
         if (IAS > (Vft - 20))
         {
             System.Media.SoundPlayer myPlayer;
             myPlayer = new System.Media.SoundPlayer(Properties.Resources.checkflaps);
             myPlayer.PlaySync();
         }
     }
     else if (flaps > 33 && flaps <= 100)
     {
         if (IAS > (Vfl - 20))
         {
             System.Media.SoundPlayer myPlayer;
             myPlayer = new System.Media.SoundPlayer(Properties.Resources.checkflaps);
             myPlayer.PlaySync();
         }
     }
     if (flaps != 0 && flaps != 20 && flaps != 33 && flaps != 100)
     {
         FLTransit = true;
     }
     if (FLTransit == true)
     {
         if (flaps == 0)
         {
             FLTransit = false;
             //call flaps 0
             System.Media.SoundPlayer myPlayer;
             myPlayer = new System.Media.SoundPlayer(Properties.Resources.flapsupamericanfemale);
             myPlayer.PlaySync();
         }
         if (flaps == 20)
         {
             //call flaps 20
             System.Media.SoundPlayer myPlayer;
             myPlayer = new System.Media.SoundPlayer(Properties.Resources.FlapsCombat);
             myPlayer.PlaySync();
             FLTransit = false;
         }
         if (flaps == 33)
         {
             //call flaps 33
             System.Media.SoundPlayer myPlayer;
             myPlayer = new System.Media.SoundPlayer(Properties.Resources.FlapsTakeoff);
             myPlayer.PlaySync();
             FLTransit = false;
         }
         if (flaps == 100)
         {
             FLTransit = false;
             //call flaps 100
             System.Media.SoundPlayer myPlayer;
             myPlayer = new System.Media.SoundPlayer(Properties.Resources.FlapsLand);
             myPlayer.PlaySync();
         }
     }
 }
コード例 #31
0
        private void getData()
        {
            try
            {
                myIndicator = JsonSerializer._download_serialized_json_data <indicator>(indicatorsurl);
                myState     = JsonSerializer._download_serialized_json_data <state>(statesurl);



                if (myState.valid == "true")
                {
                    decimal G        = Convert.ToDecimal(myState.Ny, culture);
                    decimal AoA      = Convert.ToDecimal(myState.AoA, culture);
                    decimal Alt      = Convert.ToDecimal(myIndicator.altitude_hour, culture);
                    decimal Vspeed   = Convert.ToDecimal(myState.Vy, culture);
                    int     Fuel     = Convert.ToInt32(myState.Mfuel) * 1000;                                   //MFuel and MFuel0 are given in integers
                    int     FuelFull = Convert.ToInt32(myState.Mfuel0);
                    int     Throttle = Convert.ToInt32(Convert.ToDecimal(myIndicator.throttle, culture) * 100); //TODO throttle variable only avialble in single engine aircraft
                    int     gear     = Convert.ToInt32(myState.gear);
                    int     IAS      = Convert.ToInt32(myState.IAS);                                            //unreliable?
                    int     flaps    = Convert.ToInt32(myState.flaps);
                    label.Content = myIndicator.type;

                    //BINGO FUEL
                    if (Fuel / FuelFull < 103 && Fuel / FuelFull > 100)
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.Bingo);
                        myPlayer.PlaySync();
                    }

                    //STALL WARNING
                    if (cbx_a.IsChecked == true)
                    {   //Stall Warning Mandatory pre-definitnions
                        System.Media.SoundPlayer stall1;
                        System.Media.SoundPlayer stall2;
                        stall1 = new System.Media.SoundPlayer(Properties.Resources.AngleOfAttackOverLimit);
                        stall2 = new System.Media.SoundPlayer(Properties.Resources.MaximumAngleOfAttack);

                        if (AoA > User.Default.AoA && AoA < 20 && (myIndicator.gears_lamp == "1" || IAS > 100))
                        {
                            if (AoA < User.Default.AoA + 2)
                            {
                                stall1.Stop();
                                stall2.PlayLooping();
                            }
                            else
                            {
                                stall2.Stop();
                                stall1.PlayLooping();
                            }//multi-layer AoA warnings as a variable-pitch isn't supported by MS's package
                        }
                        else
                        {
                            stall1.Stop(); stall2.Stop();
                        }
                    }

                    //G OVERLOAD
                    if (cbx_g.IsChecked == true)
                    {
                        System.Media.SoundPlayer G1;
                        System.Media.SoundPlayer G2;
                        G1 = new System.Media.SoundPlayer(Properties.Resources.OverG);
                        G2 = new System.Media.SoundPlayer(Properties.Resources.GOverLimit);
                        if (G > User.Default.GForce)
                        {
                            if (G > User.Default.GForce + 4 - User.Default.GForce / (decimal)4)
                            {
                                G1.Stop();
                                G2.PlaySync();
                            }
                            else
                            {
                                G2.Stop();
                                G1.PlaySync();
                            }
                        }
                    }

                    //PULL UP Ground Proximity Warning
                    if (((0 - Vspeed) * ((IAS - 60) / 60 + (decimal)0.5)) > (Alt + 300))
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.PullUp);
                        myPlayer.PlaySync();
                    }

                    //=========LOW PRIORITY WARNINGS=======
                    //GEAR UP/DOWN
                    if (User.Default.EnableGear == true && gear == 100 && IAS > User.Default.GearUp && myIndicator.gears_lamp == "0")
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.GearUp);
                        myPlayer.PlaySync();
                    }

                    if (User.Default.EnableGear == true && (AoA < 20 || Vspeed > -10) && gear == 0 &&
                        IAS < User.Default.GearDown && IAS > 40 && Throttle < 20 && myIndicator.gears_lamp != "0" /*Alt < 500 && flaps > 20*/)
                    {
                        System.Media.SoundPlayer myPlayer;
                        myPlayer = new System.Media.SoundPlayer(Properties.Resources.GearDown);
                        myPlayer.PlaySync();
                    }
                }
                else
                {
                    dispatcherTimer1.Stop();
                    dispatcherTimer2.Start();
                }
            }
            catch (Exception ex)
            {
                tbx_msgs.Text = ex.Message;
                dispatcherTimer1.Stop();
                dispatcherTimer2.Start();
            }
        }
コード例 #32
0
        static void Main(string[] args)
        {
            Random random = new Random();

            string[,] minutten = new string[16, 12];
            string[,] trioen   = new string[16, 6];
            int dice1;
            int dice2;
            int dice1Random;
            int dice2Random;
            int indexMin = 0;
            int indexTri = 0;

            System.Media.SoundPlayer sp = new System.Media.SoundPlayer();

            for (int i = 0; i < 16; i++)
            {
                dice2       = random.Next(2, 12);
                dice2Random = random.Next(1, 176);
                for (int j = 0; j < 12; j++)
                {
                    if (j == dice2)
                    {
                        minutten[i, dice2] = @"C:\Users\mike5171\Desktop\Wave\M"
                                             + dice2Random + ".wav";
                        indexMin++;
                        sp.SoundLocation = minutten[i, dice2];
                        sp.Load();
                        sp.PlaySync();
                        Console.WriteLine("{0},{1}", minutten[i, dice2], indexMin);
                    }
                }
            }

            Console.WriteLine("");

            for (int i = 0; i < 16; i++)
            {
                dice1       = random.Next(1, 6);
                dice1Random = random.Next(1, 96);
                for (int j = 0; j < 6; j++)
                {
                    if (j == dice1)
                    {
                        trioen[i, dice1] = @"C:\Users\mike5171\Desktop\Wave\T"
                                           + dice1Random + ".wav";
                        indexMin++;
                        sp.SoundLocation = trioen[i, dice1];
                        sp.Load();
                        sp.PlaySync();
                        Console.WriteLine("{0},{1}", trioen[i, dice1], indexMin);
                    }
                }
            }



            //Random r = new Random();
            //int index = 0;

            //int[,] minuttenArray = new int[11,16];
            //int row = 10;
            //int columns = 15;
            //for (int i = 0; i < row; i++)
            //{
            //    for (int j = 0; j < columns; j++)
            //    {
            //        minuttenArray[row, columns] = r.Next(1, 150);
            //    }
            //}

            ////for (int i = 0; i < minuttenArray.Length; i++)
            ////{
            ////    Console.WriteLine(i);
            ////}

            ////Console.ReadLine();

            //Random random = new Random();
            //int dice1 = random.Next(0, 11);
            //int dice2 = random.Next(0, 16);
            //string diceresult = Convert.ToString(dice1);
            //string dicereulst2 = Convert.ToString(dice2);
            //string[] mFiles = Directory.GetFiles(@"C:\Users\mike5171\Desktop\Wave", "M*.wav");
            //System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
            //Console.WriteLine(dice1);
            //Console.WriteLine(dice2);
            //var castresult = Convert.ToString(minuttenArray[dice1, dice2]);
            //Console.WriteLine(castresult);
            //foreach (string c in mFiles)
            //{
            //    sp.SoundLocation = c;
            //    sp.Load();
            //    sp.PlaySync();
            //    Console.WriteLine(c);

            //}



            ////for (int i = 0; i < 16; i++)
            ////{
            ////    for (int j = 0; j < 2; j++)
            ////    {
            ////        if (j <= 1)
            ////        {

            ////            minuttenArray[i, j] = @"C:\Users\mike5171\Desktop\Wave\M"
            ////                                  + index + ".wav";
            ////        }
            ////        else
            ////        {
            ////            minuttenArray[i, j] = @"C:\Users\mike5171\Desktop\Wave\T"
            ////                                  + index + ".wav";
            ////        }

            ////        index++;
            ////    }


            ////}

            //for (int i = 0; i < 16; i++)
            //{
            //    for (int j = 0; j < 1; j++)
            //    {
            //        dice1 = random.Next(2, 12);
            //        minuttenArray[i, j] = dice1;
            //    }
            //}

            ////System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
            ////foreach (string musicFile in minuttenArray)
            ////{
            ////    sp.SoundLocation = musicFile;
            ////    sp.Load();
            ////    sp.PlaySync();
            ////    Console.WriteLine(musicFile);
            ////}
        }
コード例 #33
0
 /// <summary>
 /// plays buzzer to indicate invalid input or error
 /// </summary>
 public void ErrorBuzz()
 {
     System.Media.SoundPlayer error = new System.Media.SoundPlayer(@"Sound\fail-buzzer.wav");
     error.PlaySync();
 }
コード例 #34
0
 public void playSound()
 {
     System.Media.SoundPlayer s = new System.Media.SoundPlayer(System.Environment.CurrentDirectory + "\\audio\\startup.wav");
     s.PlaySync();
     s.Dispose();
 }
コード例 #35
0
 protected virtual void PlayInternal(string path)
 {
     System.Media.SoundPlayer soundPlayer = null;
     try
     {
         soundPlayer = new System.Media.SoundPlayer(path);
         soundPlayer.PlaySync();
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex);
     }
     finally
     {
         if (null != soundPlayer)
         {
             soundPlayer.Dispose();
             soundPlayer = null;
         }
     }
 }
コード例 #36
0
 private void Ring2(object sender,JointIntersectEventArgs e)
 {
     ThreadPool.QueueUserWorkItem(new WaitCallback((_)=>
         {
             var player=new System.Media.SoundPlayer("kick.wav");
             player.PlaySync();
             player.Dispose();
         }));
     return;
 }
コード例 #37
0
ファイル: Form1.cs プロジェクト: Ikari2015/Live2D
        void AZUSAListener()
        {
            string msg = "";
            string[] parsed;
            string RID;
            string arg;
            while (!EXITING)
            {
                msg = Console.ReadLine();

                if (msg != null)
                {
                    parsed = msg.Split('(');
                    RID = parsed[0];
                    arg = msg.Replace(RID + "(", "").Trim().TrimEnd(')');

                    if (RID == "ANIMATE")
                    {

                        ANIMATE(arg);
                    }
                    else if (RID == "IMG")
                    {
                        currentAniFrames.Clear();
                        currentFrame = 0;
                        if (File.Exists(Environment.CurrentDirectory + @"\res\img\" + arg))
                        {
                            currentAniFrames.Add(@"img\" + arg);
                        }
                    }
                    else if (RID == "SAY")
                    {
                        int id = 0;
                        if (Int32.TryParse(arg.Split(',')[0], out id))
                        {

                            SAY(id, arg.Replace(id + ",", ""));
                        }
                        else
                        {
                            SAY(id, arg);
                        }
                    }
                    else if (RID == "SOUND")
                    {
                        using (System.Media.SoundPlayer player = new System.Media.SoundPlayer(Environment.CurrentDirectory + @"\res\sound\"+arg+".wav"))
                        {
                            player.PlaySync();
                        }
                    }

                }
            }
        }
コード例 #38
0
        private void PlayTask()
        {
#if DEBUG
            using (System.Media.SoundPlayer simpleSound = new System.Media.SoundPlayer(_path))
            {
                if (play != null) play(this, null);
                simpleSound.PlaySync();
                if (stopped != null) stopped(this, null);
            }
#else
            if (play != null) play(this, null);
            PlayCommand("play",_path);
            if (stopped != null) stopped(this, null);
#endif 
        }
コード例 #39
0
ファイル: Form1.cs プロジェクト: lvojp/bloodSugarLevelMeter
 private void PlaySound() {
     //オーディオリソースを取り出す
     using (System.IO.Stream strm = Properties.Resources.sound1) {
         //同期再生する
         System.Media.SoundPlayer player = new System.Media.SoundPlayer(strm);
         player.PlaySync();
     }
 }
コード例 #40
0
 public void OpenThePhone()
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"Assets/Sounds/AI2.wav");
     player.PlaySync();
 }
コード例 #41
0
        /// <summary>
        /// Emet un bip.
        /// </summary>
        public void beep()
        {
            //Il faut que le bot ne soit pas en train de se déconnecter pour émettre un bip
            if (!this.IsLoggingOut)
            {
                System.Media.SoundPlayer spBeep = new System.Media.SoundPlayer(Path.Combine(Logging.ApplicationPath, Classes.Updater.strPluginPath + "Sounds\\beep.wav"));
                spBeep.PlaySync();
                spBeep.PlaySync();
            }

        }
コード例 #42
0
ファイル: Car_UI.cs プロジェクト: RiazMahmud/Car_Project
        private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Up)
            {
                keyPress = 'u';
                g.Clear(Color.DarkSlateGray);
                c.carUp(g);
            }
            else if (e.KeyCode == Keys.Down)
            {
                keyPress = 'd';
                g.Clear(Color.DarkSlateGray);
                c.carDown(g);
            }
            else if (e.KeyCode == Keys.Left)
            {
                keyPress = 'l';
                g.Clear(Color.DarkSlateGray);
                c.carLeft(g);
            }
            else if (e.KeyCode == Keys.Right)
            {
                keyPress = 'r';
                g.Clear(Color.DarkSlateGray);
                c.carRight(g);
            }
            else if (e.KeyCode == Keys.H)
            {
                try
                {
                    System.Media.SoundPlayer player = new System.Media.SoundPlayer();
                    player.SoundLocation = "C:\\Sound\\vehicle043.wav";

                    player.Load();
                    player.PlaySync();
                }
                catch (Win32Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if (e.KeyCode == Keys.L)
            {
                c.carRightSideLight(g);
            }
            else if (e.KeyCode == Keys.K)
            {
                c.carLeftSideLight(g);
            }
            else if (e.KeyCode == Keys.S)
            {
                c.carRight(g);

                if (bl.speedCalculation() != 0 && !String.IsNullOrEmpty(currentInfoLabel.Text))
                {
                    timer1.Interval = bl.speedCalculation();
                    timer1.Start();
                }
            }
            else if (e.KeyCode == Keys.B)
            {
                timer1.Stop();
            }
        }
コード例 #43
0
ファイル: ssktts_source.cs プロジェクト: apancik/SSKTTS
        /// <summary>
        /// Reads aloud string passed in parameter. Automatically detects available syllables or word parts from data direcory (Path is specified in DATA_PATH constant).
        /// </summary>
        /// <param name="input">String used as for slovak reading routine.</param>
        public static void TellString(string input)
        {
            List<string> syllables = new List<string>();

            DirectoryInfo directory = new DirectoryInfo(DATA_PATH);

            foreach (FileInfo file in directory.GetFiles("*.wav"))
            {
                if (file.Name.Substring(0, file.Name.Length - file.Extension.Length) != SPACE_NAME) syllables.Add(file.Name.Substring(0, file.Name.Length - file.Extension.Length));
            }

            Queue<string> readingQueue = new Queue<string>();

            foreach (string word in input.Replace("q", "k").Replace("w", "v").Replace("ä","e").Replace("nn","n").Replace(":",".").ToLower().Split(' '))
            {
                string wordPart = word;
                while (wordPart != "")
                {
                    string longestSyllable = "";
                    foreach (string syllable in syllables)
                    {
                        if (wordPart.StartsWith(syllable) && syllable.Length > longestSyllable.Length) longestSyllable = syllable;
                    }
                    if (longestSyllable == "") break;
                    readingQueue.Enqueue(longestSyllable);
                    wordPart = wordPart.Remove(0, longestSyllable.Length);
                }
                readingQueue.Enqueue(SPACE_NAME);
            }

            System.Media.SoundPlayer player = new System.Media.SoundPlayer();

            while (readingQueue.Count > 0)
            {
                player.SoundLocation = DATA_PATH + readingQueue.Dequeue() + ".wav";
                player.PlaySync();
            }
        }
コード例 #44
0
        public static int Main()
        {
            /*			try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Debug.Listeners.Add(new ConsoleTraceListener());

                Application.ThreadException += delegate (object sender, System.Threading.ThreadExceptionEventArgs ee)
                {
                    Trace.WriteLine(ee.Exception.ToString());
                    Trace.Flush();

                    MessageBox.Show(ee.Exception.ToString(), ee.Exception.Message);

                    Environment.Exit(1);
                };
                AppDomain.CurrentDomain.UnhandledException += delegate (object sender, UnhandledExceptionEventArgs ee)
                {
                    Trace.WriteLine(ee.ExceptionObject.ToString());
                    Environment.Exit(1);
                };

                if (CommandLineManager.IsSpecified("help"))
                {
                    Trace.Write(CommandLineManager.GetUsage());
                    return 0;
                }
                if (CommandLineManager.IsSpecified("showargs"))
                {
                    string[] args = new string[CommandLineManager.Arguments.Count];
                    for (int i = 0; i < args.Length; i++)
                    {
                        args[i] = CommandLineManager.Arguments[i].Text;
                    }
                    Trace.WriteLine(string.Join(", ", Util.ToArray(args)));
                }
                if (CommandLineManager.IsSpecified("log"))
                {
                    Debug.Listeners.Add(new TextWriterTraceListener(Util.ApplicationName + ".log"));
                }

                Run();

                return 0;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return 1;
            }*/

            try
            {
                var soundFiles = CommandLineManager.GetValues("");
                foreach (var soundFile in soundFiles)
                {
                    var soundPlayer = new System.Media.SoundPlayer(soundFile);
                    soundPlayer.PlaySync();
                }
                return 0;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
                return 1;
            }
        }
コード例 #45
0
        private void PlaySound(BuildResult result)
        {
            var path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
            var file = "";

            if (result.IsSuccess)
            {
                file = "success.wav";
            }
            else if (result.IsFailure)
            {
                file = "failure.wav";
            }
            else if (result.IsUnstable)
            {
                file = "unstable.wav";
            }
            else if (result.IsAborted)
            {
                file = "aborted.wav";
            }
            else
            {
                return;
            }

            var wavPath = System.IO.Path.Combine(path, file);
            if (System.IO.File.Exists(wavPath))
            {
                try
                {
                    using (var player = new System.Media.SoundPlayer(wavPath))
                    {
                        player.PlaySync();
                    }
                }
                catch (Exception)
                {
                    /* Do nothing */
                    throw;
                }
            }
        }
コード例 #46
0
ファイル: Redbrick.cs プロジェクト: kcjuntunen/Redbrick-Addin
 /// <summary>
 /// Copy to_clip to clipboard.
 /// </summary>
 /// <param name="to_clip">A string.</param>
 public static void Clip(string to_clip)
 {
     if ((to_clip != null && to_clip != string.Empty) && to_clip != System.Windows.Forms.Clipboard.GetText()) {
     System.Windows.Forms.Clipboard.SetText(to_clip.Replace(Properties.Settings.Default.NotSavedMark, string.Empty));
     if (Properties.Settings.Default.MakeSounds) {
       try {
     System.Media.SoundPlayer sp = new System.Media.SoundPlayer(Properties.Settings.Default.ClipboardSound);
     sp.PlaySync();
       } catch (Exception ex) {
     RedbrickErr.ErrMsg em = new RedbrickErr.ErrMsg(ex);
     em.ShowDialog();
       }
     }
       } else {
     if (Properties.Settings.Default.MakeSounds) {
       System.Media.SystemSounds.Asterisk.Play();
     }
       }
 }
コード例 #47
0
        private string PlayCommand(string command, string arg)
        {
            if (Thalamus.ThalamusClient.IsLinux)
            {
                string retMessage = String.Empty;
                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                System.Diagnostics.Process p = new System.Diagnostics.Process();

                startInfo.CreateNoWindow = true;
                startInfo.RedirectStandardOutput = true;
                startInfo.RedirectStandardInput = true;

                startInfo.UseShellExecute = false;
                startInfo.Arguments = arg;
                startInfo.FileName = command;

                p.StartInfo = startInfo;
                p.Start();

                p.WaitForExit();
                string s = p.StandardOutput.ReadToEnd();
                Console.WriteLine(s);
                return s;
            }
            else
            {
                System.Media.SoundPlayer player = new System.Media.SoundPlayer(@arg);
                player.PlaySync();
                return "";
            }
        }
コード例 #48
0
ファイル: MainWindow.xaml.cs プロジェクト: mikeyhalla/GClient
 private void scrollviewer1_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         var uie = e.OriginalSource as UIElement;
         if (e.Key == Key.Down)
         {
             e.Handled = true;
             uie.MoveFocus(new TraversalRequest(FocusNavigationDirection.Down));
             System.Media.SoundPlayer sound = new System.Media.SoundPlayer(Properties.Resources.button);
             sound.PlaySync();
         }
         if (e.Key == Key.Up)
         {
             e.Handled = true;
             uie.MoveFocus(new TraversalRequest(FocusNavigationDirection.Up));
             System.Media.SoundPlayer sound = new System.Media.SoundPlayer(Properties.Resources.button);
             sound.PlaySync();
         }
         if (e.Key == Key.Right)
         {
             e.Handled = true;
             uie.MoveFocus(new TraversalRequest(FocusNavigationDirection.Right));
             System.Media.SoundPlayer sound = new System.Media.SoundPlayer(Properties.Resources.button);
             sound.PlaySync();
         }
         if (e.Key == Key.Left)
         {
             e.Handled = true;
             uie.MoveFocus(new TraversalRequest(FocusNavigationDirection.Left));
             System.Media.SoundPlayer sound = new System.Media.SoundPlayer(Properties.Resources.button);
             sound.PlaySync();
         }
         if (e.Key == Key.Escape)
         {
             Variables.Exiting = true;
             GamePadState currentState = GamePad.GetState(PlayerIndex.One);
             if (currentState.IsConnected)
             {
                 wrapPanel1.Children.Clear();
                 wrapPanel1.Visibility = Visibility.Hidden;
                 textBox2.Visibility = Visibility.Visible;
                 Thread thread = new Thread(ClearHide);
                 thread.IsBackground = true;
                 thread.Start();
                 Variables.minimize = true;
                 Variables.active = false;
                 Variables.close = true;
                 if (Variables.Fan)
                 {
                     try
                     {
                         using (Process proc = new Process())
                         {
                             proc.StartInfo.FileName = Environment.CurrentDirectory + @"\FanControl\FanOff.exe";
                             proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                             proc.Start();
                         }
                         Variables.Fan = false;
                     }
                     catch (Exception ex)
                     {
                         Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + "          " + ex.Message);
                         MessageBox.Show(Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n\n" + ex.Message, Properties.Resources.ResourceManager.GetString("FailedOperationTitle"), MessageBoxButton.OK, MessageBoxImage.Stop);
                     }
                 }
             }
             else
             {
                 wrapPanel1.Children.Clear();
                 wrapPanel1.Visibility = Visibility.Hidden;
                 textBox2.Visibility = Visibility.Visible;
                 Thread thread = new Thread(ClearHide);
                 thread.IsBackground = true;
                 thread.Start();
                 Variables.active = false;
                 Variables.GamePadConnected = false;
                 Variables.close = true;
                 if (Variables.Fan)
                 {
                     try
                     {
                         using (Process proc = new Process())
                         {
                             proc.StartInfo.FileName = Environment.CurrentDirectory + @"\FanControl\FanOff.exe";
                             proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                             proc.Start();
                         }
                         Variables.Fan = false;
                     }
                     catch (Exception ex)
                     {
                         Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + "          " + ex.Message);
                         MessageBox.Show(Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n\n" + ex.Message, Properties.Resources.ResourceManager.GetString("FailedOperationTitle"), MessageBoxButton.OK, MessageBoxImage.Stop);
                     }
                 }
             }
         }
         if (e.Key == Key.Enter)
         {
             e.Handled = true;
             try
             {
                 Thread.Sleep(50);
                 if (Variables.Game != "0" && !Variables.GameRunning)
                 {
                     Variables.GameRunning = true;
                     Thread thread = new Thread(RunGame);
                     thread.IsBackground = true;
                     thread.Start();
                 }
                 else
                 {
                     try
                     {
                         Directory.CreateDirectory(Variables.TempPath);
                         File.Copy(Variables.GameListX, Variables.TempFile, true);
                         wrapPanel1.Visibility = Visibility.Hidden;
                         Thread th = new Thread(SteamHide);
                         th.Start();
                         using (Process process = new Process())
                         {
                             process.StartInfo.FileName = Environment.CurrentDirectory + @"\AddGames.exe";
                             process.Start();
                         }
                     }
                     catch (Exception ex)
                     {
                         Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + "          " + ex.Message);
                     }
                 }
             }
             catch (Exception ex)
             {
                 Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + "          " + ex.Message);
                 MessageBox.Show(Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n\n" + ex.Message, Properties.Resources.ResourceManager.GetString("FailedOperationTitle"), MessageBoxButton.OK, MessageBoxImage.Stop);
             }
         }
     }
     catch (Exception ex)
     {
         Trace.WriteLine(DateTime.Now + Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n" + "          " + ex.Message);
         MessageBox.Show(Properties.Resources.ResourceManager.GetString("FailedOperationMessage") + "\n\n" + ex.Message, Properties.Resources.ResourceManager.GetString("FailedOperationTitle"), MessageBoxButton.OK, MessageBoxImage.Stop);
     }
 }