Main Archive Specials Wiki | FAQ Links Submit Forum

 quick and dirty sine generatorType : sine generatorReferences : Posted by couriervst[AT]hotmail[DOT]comNotes : this is part of my library, although I've seen a lot of sine generators, I've never seen the simplest one, so I try to do it, tell me something, I've try it and work so tell me something about it Code : PSPsample PSPsin1::doOsc(int numCh) { double x=0; double t=0; if(m_time[numCh]>m_sampleRate) //re-init cycle m_time[numCh]=0; if(m_time[numCh]>0) { t =(double)(((double)m_time[numCh])/(double)m_sampleRate); x=(m_2PI *(double)(t)*m_freq); } else x=0; PSPsample r=(PSPsample) sin(x+m_phase)*m_amp; m_time[numCh]++; return r; }

 CommentsAdded on : 08/01/04 by pete[ AT ]bannister25[ DOT ]plus[ DOT ]comComment : isn't the sin() function a little bit heavyweight?  Since this is based upon slices of time, would it not be much more processor efficient to use a state variable filter that is self oscillating? The operation: t =(double)(((double)m_time[numCh])/(double)m_sampleRate); also seems a little bit much, since t could be calculated by adding an interval value, which would eliminate the divide (needs more clocks).  The divide would then only need to be done once. An FDIV may take 39 clock cycles minimum(depending on the operands), whilst an FADD is far faster (3 clocks).  An FMUL is comparable to an add, which would be a predominant instruction if using the SVF method. FSIN may take between 16-126 clock cylces. (clock cycle info nabbed from: http://www.singlix.com/trdos/pentium.txt) Added on : 09/01/04 by rossb[ AT ]audiomulch[ DOT ]comComment : See also the fun with sinusoids page: http://www.audiomulch.com/~rossb/code/sinusoids/Added on : 18/11/14 by ant[ DOT ]stewart[ AT ]yahoo[ DOT ]comComment : For audio generation, sines are expensive i think, they are so perfect and take up more processing. it's rare to find a synth that sounds nicer with a sine compared to a parabol wave. My favourite parabolic wave is simply triangle wave with x*x with one of the half periods flipped. x*x is a very fast!!!Added on : 06/12/14 by kalle[ DOT ]muenster[ AT ]gmx[ DOT ]deComment : hmm... x*x second half flipped... very cool ! i'll give it a try!!Added on : 18/02/17 by krupskayaulyanova[ AT ]mail[ DOT ]ruComment : I bought the cat didn't know what to call him. Found here full list unique kitten names http://allcatsnames.com/girl-kitten-names-unique of names for cats.

 Add your own comment Comments are displayed in fixed width, no HTML code allowed! Email: Comment: Are you human?

Site created and maintained by Bram
Graphic design by line.out | Server sponsered by fxpansion