help oscillator pitch problem
-
- KVRer
- Topic Starter
- 15 posts since 7 Jul, 2004
Hi folks, I get a big trouble which make me sad !
this is my situation,
I have an oscillator see www.musicdsp.com "quick and dirty" than I've a good and working routine which give me a envelope, so I put envelope result into freq var and the result it's a no sense wave.
Can U help me?
Thanks
this is my situation,
I have an oscillator see www.musicdsp.com "quick and dirty" than I've a good and working routine which give me a envelope, so I put envelope result into freq var and the result it's a no sense wave.
Can U help me?
Thanks
-
- KVRer
- 18 posts since 20 Nov, 2003 from Pittsburgh, PA
Have you tested the oscillator code without modulation the frequency value? What values is your envelope putting out and what values is the oscillator expecting? You've got three potential problems (the oscillator code may not work, the envelope code may not work, and the envelope output may not make sense as a frequency input) - so isolate your problem first.
-
- KVRer
- Topic Starter
- 15 posts since 7 Jul, 2004
Thank 4 Ur answer,
yep I've tested all the 3 point, oscillator work, emvelope work, and output of envelope get richt sense... this problem make me crazy, U know if there is a source of an effect like bdrum synth or so on
thanks Again
yep I've tested all the 3 point, oscillator work, emvelope work, and output of envelope get richt sense... this problem make me crazy, U know if there is a source of an effect like bdrum synth or so on
thanks Again
-
- KVRian
- 922 posts since 26 Mar, 2003 from Guildford, England
Try this for the oscillator instead:
Also not a great way of producing a sine. It works well, but could be much faster.
The frequency should be supplied in whatever units the samplerate is in, so if you've got this from a vsttimeinfo struct, you'll want it to be in Hz.
You could get rid of the PI/sr in the frequency calculation by precalculating it.
Code: Select all
const double PI = 3.1415926535897932384626433832795;
const double TWO_PI = PI * 2;
class Osc
{
public:
Osc() : amp_(1.0), phs_(0.0), pinc_(0.0) { }
inline void setAmp(double amp) { amp_ = amp; }
inline void setFrequency(double f, double sr) { pinc_ = f * PI / sr; }
inline double dirtySine();
private:
double amp_;
double phs_;
double pinc_;
};
inline double
Osc::dirtySine()
{
double p = phs_ + pinc_;
if (p > TWO_PI) {
p -= TWO_PI;
}
phs_ = p;
return (amp_ * sin(p));
}
The frequency should be supplied in whatever units the samplerate is in, so if you've got this from a vsttimeinfo struct, you'll want it to be in Hz.
You could get rid of the PI/sr in the frequency calculation by precalculating it.
-
- KVRer
- Topic Starter
- 15 posts since 7 Jul, 2004
you great thanks I will try it soon as possible...
just a question which kind of site is yours? I don't understand, self music promotion or music shop
You keep my curiosity
Paul
just a question which kind of site is yours? I don't understand, self music promotion or music shop
You keep my curiosity
Paul
-
- KVRian
- 922 posts since 26 Mar, 2003 from Guildford, England
The site is basically for promoting music, although itreally needs sorting out. Some of the tracks have been signed, so we've had to take down the audio from the site. There are demos at the bitboutique site and at the iron box site though.
-
- KVRer
- Topic Starter
- 15 posts since 7 Jul, 2004
texture U R GREAT! seems to work...
thanks again
thanks again
-
- KVRAF
- 4641 posts since 20 Feb, 2004 from Gothenburg, Sweden
I guess this was the old accumating problem?
doing phase = time*freq instead of phase += deltaTime*freq.
doing phase = time*freq instead of phase += deltaTime*freq.
Stefan H Singer
Musician, coder and co-founder of We made you look Web agency
Musician, coder and co-founder of We made you look Web agency
-
- KVRian
- 922 posts since 26 Mar, 2003 from Guildford, England
Looked like it was both!stefancrs wrote:I guess this was the old accumating problem?
doing phase = time*freq instead of phase += deltaTime*freq.
There appeared to be an array of integer accumulators (for multiple channels?). These then got converted to doubles on every iteration and divided by the samplerate (also converted from int to double). This gave the time of one cycle.
The phase was then calculated from the cycle time, in radians and added to a phase variable before applying the sin() function.
Obviously using sin() to calculate the waveform is pretty unneccesary, as a self oscillating IIR would be far more efficient.
-
- KVRian
- 922 posts since 26 Mar, 2003 from Guildford, England
glad it workscouriervst wrote:texture U R GREAT! seems to work...
thanks again