# Get this song stuck in my head [duplicate]

Your challenge is to play these notes (speakers or to a sound file) in this order:

C
A
F
G


Specifically, you must play these frequencies one after the other:

261.63 Hz
220.00 Hz
174.61 Hz
196.00 Hz


with an allowed error of +/- 5 Hz.

If you output to a file, please use a .ogg or .mp3, or raw bytes that can be fed to aplay. The notes must last at least 100ms, and less than 5s. They must be played for the same duration.

No, this is not a converter from notes to a sound file! You just need to play some frequencies!

## marked as duplicate by Erik the Outgolfer, Rɪᴋᴇʀ, Wheat Wizard, user62131 May 24 '17 at 4:56

• Please consider using the Sandbox in the future to get feedback on your challenges before posting them to the main site. – Mego May 16 '17 at 15:57
• Part of the problem is probably that I had to look up chord, but even now that I did, I'm not sure how to translate chords into something a computer can understand, how C,Am,F,G is a transposition of F,Dm,A#,C, what exactly you mean by in any format, and which methods of "playing" are acceptable. – Dennis May 16 '17 at 15:58
• This seems like a simpler version of codegolf.stackexchange.com/q/11463/194 or codegolf.stackexchange.com/q/272/194 and I'm not sure what it adds to the site. – Peter Taylor May 16 '17 at 16:15
• Play how? One after the other or all at once? For how long? Once or in a loop? Are these the only allowed frequencies? If not, which ones are allowed? Which formats for "sound files" are acceptable? – Dennis May 16 '17 at 17:55
• Having read the history, I think it's sad what happened. You wanted chords, but nonmusicians didn't get it. Then you said it was OK to do either chords or just root notes (but chords need more code so why do them?) and nonmusicians were confused by transposition. Finally you restricted to one key, but tried to be flexible on octaves (but didn't explain that meant frequencies could be multiplied by powers of 2) so you were forced to restrict to a single octave. It's a good question but if it had been sandboxed it might've been received better in a form closer to your original intention. – Level River St May 16 '17 at 22:07

# JS, 254 bytes

Gets annoying after a while. Weird things happen when used in multiple tabs.

c=new AudioContext();x=c.createOscillator();x.type="sine";x.frequency.value=261.63;x.start(0);y=c.createGain();n=y.gain.value=0;x.connect(y);y.connect(c.destination);setInterval(()=>(x.frequency.value=[261.63,220,174.61,196][n%4],n++,y.gain.value=1),500)

• Why the downvote? – programmer5000 May 16 '17 at 20:16
• heheh, I can slow down a note by vigorously scrolling my browser. – Level River St May 16 '17 at 21:51

# Bash + beep, 32 bytes

beep -f261 -nf220 -nf175 -nf196


If the pcspkr module isn't loaded, it must be loaded by the script, and it counts toward the byte count, then add 'insmod pcspkr\n' to the beginning, change to 36 bytes, and run as root.

# C#, 93 bytes

()=>{var k=new int[]{261,220,174,196};for (int s=0;s<4;s++){System.Console.Beep(k[s],500);}};


## Python 2, 61 bytes

from winsound import*
exec'Beep(%s,100);'*4%(261,220,174,196)


# C++ (windows), 84 bytes

include<windows.h>
int i;void f(){Beep((int[]){261,220,174,196}[i++],500);i<4&&f();}