giganciprogramowania

l14

Nov 12th, 2024
6
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //star wars
  2. int[] melodia = { 440, 440, 440, 349, 523, 440, 349, 523, 440, 0, 659, 659, 659, 698, 523, 415, 349, 523, 440, 0, 880, 880, 440, 440, 880, 831, 784, 698, 740, 0, 622, 659, 415, 440, 523, 0, 440, 523, 440, 0 };
  3.  
  4. int[] czasTrwania = { 500, 500, 500, 350, 150, 500, 350, 150, 650, 500, 500, 500, 500, 350, 150, 500, 350, 150, 650, 500, 500, 500, 350, 150, 500, 350, 150, 650, 150, 500, 150, 500, 150, 1000, 500, 350, 150, 500, 350, 150, 650 };
  5.  
  6.  
  7. using (var waveOut = new WaveOutEvent())
  8. {
  9. for (int i = 0; i < frequencies.Length; i++)
  10. {
  11. if (frequencies[i] != 0)
  12. {
  13. var sineWave = new SignalGenerator()
  14. {
  15. Gain = 0.2,
  16. Frequency = frequencies[i],
  17. Type = SignalGeneratorType.Sin
  18. }.Take(TimeSpan.FromMilliseconds(durations[i]));
  19.  
  20. waveOut.Init(sineWave);
  21. waveOut.Play();
  22. while (waveOut.PlaybackState == PlaybackState.Playing)
  23. {
  24. Thread.Sleep(10);
  25. }
  26. }
  27. else
  28. {
  29. Thread.Sleep(durations[i]);
  30. }
  31. }
  32. }
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. //Mario Bros
  40. int[] melodia = { 659, 659, 0, 659, 0, 523, 659, 0, 784, 0, 392, 0, 523, 0, 392, 0, 330, 0, 440, 494, 0, 466, 0, 440, 0, 392, 659, 0, 784, 780, 0, 784, 0, 659, 0, 523, 587, 0, 494, 0, 523, 0, 392, 0, 330, 0, 440, 494, 0, 466, 0, 440, 0 };
  41.  
  42. int[] czasTrwania = { 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 400, 200, 200, 200, 400, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 400, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200 };
  43.  
  44. using (var waveOut = new WaveOutEvent())
  45. {
  46. for (int i = 0; i < frequencies.Length; i++)
  47. {
  48. if (frequencies[i] != 0)
  49. {
  50. var sineWave = new SignalGenerator()
  51. {
  52. Gain = 0.2,
  53. Frequency = frequencies[i],
  54. Type = SignalGeneratorType.Sin
  55. }.Take(TimeSpan.FromMilliseconds(durations[i]));
  56.  
  57. waveOut.Init(sineWave);
  58. waveOut.Play();
  59. while (waveOut.PlaybackState == PlaybackState.Playing)
  60. {
  61. Thread.Sleep(10);
  62. }
  63. }
  64. else
  65. {
  66. Thread.Sleep(durations[i]);
  67. }
  68. }
  69. }
  70.  
  71.  
  72.  
  73.  
  74.  
Add Comment
Please, Sign In to add comment