-5
\$\begingroup\$

This question already has an answer here:

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!

\$\endgroup\$

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 8
    \$\begingroup\$ Please consider using the Sandbox in the future to get feedback on your challenges before posting them to the main site. \$\endgroup\$ – Mego May 16 '17 at 15:57
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ – Dennis May 16 '17 at 15:58
  • 3
    \$\begingroup\$ 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. \$\endgroup\$ – Peter Taylor May 16 '17 at 16:15
  • 4
    \$\begingroup\$ 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? \$\endgroup\$ – Dennis May 16 '17 at 17:55
  • 3
    \$\begingroup\$ 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. \$\endgroup\$ – Level River St May 16 '17 at 22:07
3
\$\begingroup\$

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)

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

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.

\$\endgroup\$
1
\$\begingroup\$

C#, 93 bytes

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

Python 2, 61 bytes

from winsound import*
exec'Beep(%s,100);'*4%(261,220,174,196)
\$\endgroup\$
1
\$\begingroup\$

C++ (windows), 84 bytes

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.