Пример #1
0
void testSquareWave()
{
	std::ofstream file("../results/square_wave.dat", std::ios::out);

	for (verve::real currentTime=0; currentTime < gMaxTime; currentTime += gDT)
	{
		verve::real input = squareWave(currentTime, (verve::real)0.5*gWaveAmplitude, gWaveFrequency);
		verve::real output = activateNeuron(input, gDT);
		file << currentTime << " " << input << " " << output << std::endl;
	}

	file.close();
}
Пример #2
0
/*
short sinTable[] = {0, 6, 12, 18, 24, 30, 36, 42, 48, 53, 58, 63, 68, 72, 77, 80, 84, 87, 90, 92, 95, 96, 98, 99, 99, 99, 99, 99, 98, 96, 95, 93, 90, 87, 84, 80, 77, 72, 68, 63, 58, 53, 48, 42, 36, 31, 25, 18, 12, 6, 0, -6, -12, -18, -24, -30, -36, -42, -48, -53, -58, -63, -68, -72, -76, -80, -84, -87, -90, -92, -95, -96, -98, -99, -99, -99, -99, -99, -98, -96, -95, -93, -90, -87, -84, -81, -77, -73, -68, -63, -59, -53, -48, -42, -37, -31, -25, -19, -12, -6};

Simple sinus aproximation with a lookup table.  
This is defined via what tone is currently playing on the channel we are generating for and what state we currently are at. 
State is a constantly incrementing value for each interrupt. This makes the function below able to determine where it should be in its waveform 
short sinWave(){
	int period = soundState%samplesPerPeriod;
	short index = (period*100)/samplesPerPeriod;
	return sinTable[index%100];

}
*/
short waveFunction(){
	soundState++;
	return (unsigned int)squareWave();
}