DJm00n 03.10.2011 14:50 Vacuum-IM

Какая прелесть: генерация музыки односточниками на си.

Recommended by: @dorfe, @lHooFool, @Minoru, @utros
2. dorfe 03.10.2011 19:11

#include <windows.h>

struct BeepData
{
int duration;
int freq;
int delay;
};

static const BeepData StarWarsMarch[] =
{
{350, 392, 100},
{350, 392, 100},
{350, 392, 100},
{250, 311.1, 100},
{25, 466.2, 100},
{350, 392, 100},
{250, 311.1, 100},
{25, 466.2, 100},
{700, 392, 100},
{350, 587.32, 100},
{350, 587.32, 100},
{350, 587.32, 100},
{250, 622.26, 100},
{25, 466.2, 100},
{350, 369.99, 100},
{250, 311.1, 100},
{25, 466.2, 100},
{700, 392, 100},
{350, 784, 100},
{250, 392, 100},
{25, 392, 100},
{350, 784, 100},
{250, 739.98, 100},
{25, 698.46, 100},
{25, 659.26, 100},
{25, 622.26, 100},
{50, 659.26, 400},
{25, 415.3, 200},
{350, 554.36, 100},
{250, 523.25, 100},
{25, 493.88, 100},
{25, 466.16, 100},
{25, 440, 100},
{50, 466.16, 400},
{25, 311.13, 200},
{350, 369.99, 100},
{250, 311.13, 100},
{25, 392, 100},
{350, 466.16, 100},
{250, 392, 100},
{25, 466.16, 100},
{700, 587.32, 100},
{350, 784, 100},
{250, 392, 100},
{25, 392, 100},
{350, 784, 100},
{250, 739.98, 100},
{25, 698.46, 100},
{25, 659.26, 100},
{25, 622.26, 100},
{50, 659.26, 400},
{25, 415.3, 200},
{350, 554.36, 100},
{250, 523.25, 100},
{25, 493.88, 100},
{25, 466.16, 100},
{25, 440, 100},
{50, 466.16, 400},
{25, 311.13, 200},
{350, 392, 100},
{250, 311.13, 100},
{25, 466.16, 100},
{300, 392.00, 150},
{250, 311.13, 100},
{25, 466.16, 100},
{700, 392, 0}
};

int main()
{
for(size_t i = 0; i < sizeof(StarWarsMarch) / sizeof(StarWarsMarch[0]); i++)
{
const BeepData& data = StarWarsMarch[i];
Beep(data.freq, data.duration);
Sleep(data.delay);
}

return 0;
}

Do you really want to delete ?