Skip to main content
7 of 7
added 174 characters in body
nutki
  • 3.7k
  • 11
  • 12

Perl 5: 94 122 140

SND files have simpler headers, no need to print in binary. This versions produce 8khz mono SND file named 'a':

open A,'>a';print
A".snd",pack"N*",24,-1,2,8e3,1,map{(--$|x3)x(894261072>>$_&1?1600:400)}0..39

The result file.

Old solution. Produces a 1khz 8-bit mono WAV file named 'a':

open
A,'>a';print
A pack"A4lA8lssllssA4ls*",RIFF,17040,WAVEfmt,16,1,1,(1e3)x2,1,8,data,17004,map{($_)x(894261072>>$v++&1?400:100)}(255,0)x20

The result file.

To get to 122 characters I had to paste the header in binary instead of packing it which makes the code hard to copy here. The escaped version is:

open
A,'>a';print
A"RIFF\x90B\0\0WAVEfmt \0\0\0\0\0\xe8\0\0\xe8\0\0\0\0datalB\0\0",pack"s*",map{($_)x(894261072>>$v++&1?400:100)}(255,0)x20

Base64 encoding of the actual 122 bytes solution:

b3BlbgpBLCc+YSc7cHJpbnQKQSJSSUZGkEIAAFdBVkVmbXQgEAAAAAEAAQDoAwAA6AMAAAEACABk
YXRhbEIAACIscGFjayJzKiIsbWFweygkXyl4KDg5NDI2MTA3Mj4+JHYrKyYxPzQwMDoxMDApfSgy
NTUsMCl4MjA=
nutki
  • 3.7k
  • 11
  • 12