1 Replies - 1718 Views - Last Post: 05 January 2012 - 03:37 AM Rate Topic: -----

#1 erik.price   User is offline

  • D.I.C Lover
  • member icon

Reputation: 486
  • View blog
  • Posts: 2,690
  • Joined: 18-December 08

Metronome Using '\a' !

Posted 05 May 2009 - 03:13 PM

Description: Printing 'a' takes some time, and as a result, the beat will sound exactly the same speed no matter what the BPM is after a certain number (which I forget right now). To fix this, just remove the printf('a'); line and keep the printf("Tick..n"); line.Very basic metronome that uses 'a' (BELL) and text to keep the beat.
#include <time.h>

void waitFor(double time) //required to wait for the correct amount of time
{
	double endtime;
	endtime = clock() + (time * CLOCKS_PER_SEC);
	while(clock() < endtime){}
}

void metronome(int BPM)
{
	waitFor(60/BPM); //i.e. 10 BPM == 1 beat every 6 seconds == 60/10
	//printf('a'); 
       /*Commented out to protect you from the annoyance. Use at your own risk!*/
	printf("Tick...n"); //Feel free to change this to whatever message you want
}


Is This A Good Question/Topic? 0
  • +

Replies To: Metronome Using '\a' !

#2 111027   User is offline

  • D.I.C Head

Reputation: 17
  • View blog
  • Posts: 141
  • Joined: 26-December 11

Re: Metronome Using '\a' !

Posted 05 January 2012 - 03:37 AM

Quite decent - simple yet effective.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1