33
2
This is Weekly Challenge #1. Theme: Audio Processing
Your task is to write a program, which writes an audio file to disc (in a format of your choice), which contains the Morse code for 2015
, i.e.
..--- ----- .---- .....
You are free to choose any sort of sound for the segments, like a single-frequency sine wave, a chord, noise, some instrument (e.g. using MIDI files), as long as it's audible. However, there are some constraints on the timing:
- Short segments need to be at least 0.2 seconds in length.
- Long segments need to be at least 3 times as long as short segments.
- Breaks between segments within a digit should be the same length as short segments.
- Breaks between digits should be the same length as long segments.
- Each segment and break may deviate up to 10% from the average length of that type of segment/break.
- The entire audio file may not be longer than 30 seconds.
The breaks don't need to be completely silent, but the Morse segments should be audibly louder than the breaks.
Note that you have to write an audio file. You cannot just play the sound, e.g. using system beeps. You're allowed to use any sort of library to handle the file format and audio generation, but you must not use built-in features for Morse encoding.
This is code golf, so the shortest answer (in bytes) wins.
Please consider linking to an upload of the resulting audio file (on SoundCloud or similar), so people can check out the result without having to run your code. If you upload to SoundCloud, please make sure to enable downloads in the Permissions tab of the track.
If your output uses a rather uncommon file format, please add some information about how to play it back and/or convert it to a more common format and upload it.
Example track
This is a manually generated example track which conforms with the spec and uses noise for the Morse segments (microphone background noise, to be precise). Here is a link to SoundCloud if the embedded player doesn't work for you.
Bounty Details
I will award the bounty to the shortest submission in an audio programming language, i.e. a language that is designed to synthesise sound. That list is not complete, so feel free to use another audio programming language, if you know one. If you're not sure whether some language you want to use classifies as an audio programming language, please let me know in the comments or in chat, and we can discuss that.
Note that your submission still has to comply with all the rules - in particular, it has to write a file, which might not be possible in all audio programming languages. E.g., as far as I can tell, gibber can only play the sound and not save it to a file.
1Additional Challenge: Make it sound really nice. – Kaz Wolfe – 2015-01-02T20:47:23.140
6@Mew How nice can Morse possibly sound? – Martin Ender – 2015-01-02T21:19:35.763
1Doing this in Brainf**k would make this awesome on so many bonus levels. – Mast – 2015-01-04T17:02:54.480
@Mast Probably, but unfortunately, BF can't write to a file. ;) (I'll make sure to be more lenient with that next time.) – Martin Ender – 2015-01-04T17:03:54.447
Are music notation formats, that only contain the score and no audio (.mid, .abc seen below) considered acceptable as an "audio file"? What about "tracker" formats, that contain both samples and a score, but no rendered audio track (.mod, .xm)? – Tobia – 2015-01-06T15:42:41.300
@Tobia I would say as long as there is some audio player (that existed before this challenge was posted), which can actually play back the file, then it's an audio file. – Martin Ender – 2015-01-06T17:50:38.673
The only answers that could work for the bounty so far are the Csound, ChucK, and SuperCollider ones, right? – KSFT – 2015-01-10T21:42:16.147
@KSFT Yes, that's correct. – Martin Ender – 2015-01-10T21:48:49.120
@MartinBüttner hmm, you picked on my solution which did not write to a file and then accepted one that does not either (also does not meet the 30s requirement though ABC format allows to specify the tempo which would cost extra characters). Of course the point is moot as even after fixing I would lose by a few characters. – nutki – 2015-01-11T17:21:32.007
@nutki Thanks for pointing that out. I'll notify the OP and unaccept for now. – Martin Ender – 2015-01-11T18:31:02.597