Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Threading;
- class Note {
- public int Frequency { get; set; }
- public int Duration { get; set; }
- public Note(int frequency, int duration) {
- Frequency = frequency;
- Duration = duration;
- }
- }
- class Program {
- static void Main(string[] args) {
- // Chorus notes and durations
- Console.ReadKey();
- List<Note> chorus = new List<Note>()
- {
- new Note( 392, 60 ),
- new Note( 440, 60 ),
- new Note(523, 60 ),
- new Note(440, 60 ),
- new Note(659, 120 ),
- new Note(659, 60 ),
- new Note(587,240 ),
- new Note( 392, 60 ),
- new Note( 440, 60 ),
- new Note(523, 60 ),
- new Note(440, 60 ),
- new Note(587, 120),
- new Note(587, 60),
- new Note(523, 120),
- new Note(494, 60),
- new Note(440, 60)
- };
- // Tempo (in beats per minute)
- int bpm = 120;
- // Calculate delay between notes based on tempo
- int delay = (int)((60.0 / bpm) * 1000);
- // Play the entire chorus with the correct tempo
- for (int i = 0; i < 2; i++) // Repeat the chorus twice
- {
- foreach (var note in chorus) {
- Console.Beep(note.Frequency, (int)note.Duration *2 );
- Thread.Sleep(delay / 2);
- }
- Thread.Sleep(delay);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement