[sdiy] sine wave floating point conversion issue

dan snazelle subjectivity at hotmail.com
Sat Feb 25 04:15:32 CET 2012


that should be
> 
> If I have a value in my program that is putting out floating point values (to make a sine wave) between "-1.0 and 1.0"





On Dec 31, 2000, at 7:51 PM, dan snazelle wrote:

> If I have a value in my program that is putting out floating point values (to make a sine wave) between 0.0 and 1.0
> 
> I would like to get these values into an integer value of between 0 and 255 for my dac routine.
> 
> i tried changing the type and multiplying the value and then dividing it, but then i ended up with negative and positive values....
> 
> 
> here is the routine which MAKES the sine
> 
> 	
> 
> void loop () {
>  int FREQUENCY=25+analogRead(0);
>  float sample;
>   int j; 
> 
> 	for(j = 0; j < NUM_SAMPLES; j++) {
> 
> 		
> 
>  		sample = sin(2 * PI * FREQUENCY * j / SAMPLING_RATE);
> 
> 
> sample is the value which is a float and puts out the number I want to transform into something usable for the dacOutput function.
> 
> 
> This has shown me I need to get better and basic type conversion, etc
> 
> 
> thanks
> 
> 
> 
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at dropmix.xs4all.nl
> http://dropmix.xs4all.nl/mailman/listinfo/synth-diy
> 




More information about the Synth-diy mailing list