Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hintro

Random Synth Tone Generator using BASS library in C featuring an alarm based date string and FPS timer

Depends

Compile

cmake . --install-prefix=/usr
make install

Usage

./hintro

Keyboard Layout

  • ANY to switch random tone
  • ESC to exit sucessful
  • CTRL + C to exit failure with cleanup

Synth

#include "hintro_bass.h"

DWORD CALLBACK sound_proc(HSTREAM handle, void *buf, DWORD len, void *user)
{
	const SOUND* cfg = (SOUND*)user;
	static int cur = 0;
	memset(buf, 0, len);

	for(int c = 0; c < len / sizeof(float); c+=2)
	{
		const int     freq =     (cfg->prng + cur + 1) / 10;
		const float  phase =     (freq      * cur    ) / (float)cfg->info.freq;
		((float*)buf)[c  ] = sinf(phase     *       2  * (float)M_PI);
		((float*)buf)[c+1] = cosf(phase     *       2  * (float)M_PI);
		cur++;
		cur %= cfg->info.freq;
	}
	return len;
}

BOOL sound_loop()
{
	int prev = 0;
	int cur  = 0;

	while(cur != 27)
	{
		if((cur = term_getc()) != prev)
		{
			prev = cur;
			snd.prng = rand();
		}
		snd.frame.cnt++;
		if(snd.frame.fps > 0)
			printf("\r%s %s", snd.time.str, snd.frame.str);
	}
	return TRUE;
}

int main(int argc, char** argv)
{
	exit(snd.init(44100) && snd.play(snd.stream, FALSE) && snd.loop() ? EXIT_SUCCESS : EXIT_FAILURE);
}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages