Page 1 of 1

Was bored...

Posted: August 31st, 2011, 7:14 pm
by evilfigment
So i made the star wars theme song via computer beeps :)

Code: Register to unlock hidden link

// Star Wars Intro For Trainers
// (Requires Internal System Speaker)
//
// File: C_SWIntro.c
// Author: Evilfigment

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>


typedef struct {
	const int frequency;
	const int duration;
} snds_t;


snds_t swintro[] = 
{
	{ 293,  139 },
	{ 293,  139 },
	{ 293,  139 },
	{ 391,  834 },
	{ 587,  834 },
	{ 523,  139 },
	{ 493,  139 },
	{ 440,  139 },
	{ 783,  834 },
	{ 587,  417 },
	{ 523,  139 },
	{ 493,  139 },
	{ 440,  139 },
	{ 783,  834 },
	{ 587,  417 },
	{ 523,  139 },
	{ 493,  139 },
	{ 523,  139 },
	{ 440,  834 },
	{ 293,  139 },
}; 

const static int len_swintro = 
	sizeof( swintro ) / sizeof( swintro[0] );


void PlaySequence( snds_t *seqtbl, int numofsnds )
{
	int i;
	snds_t *p = &seqtbl[0];
	for( i = 0; i < numofsnds; p = &seqtbl[++i] )
		Beep( p->frequency, p->duration );
}


int main(int argc, char* argv[])
{
	printf("Attempting to play the Star Wars theme song..\n");
	printf("(Make sure you have an internal system speaker)\n");

	PlaySequence( swintro, len_swintro );

	printf("\n\nFinished..\nPRESS..ENTER..TO EXIT");
	getchar();

	return 0;
}