bumping version to 3.5-rc1
[supercollider.git] / server / scsynth / SC_Rate.cpp
blob04d3aa26ebb427124d62596bd12a76d48bf8d522
1 /*
2 SuperCollider real time audio synthesis system
3 Copyright (c) 2002 James McCartney. All rights reserved.
4 http://www.audiosynth.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "SC_Rate.h"
23 #include "SC_Constants.h"
24 #include "SC_Prototypes.h"
26 void Rate_Init(Rate *inRate, double inSampleRate, int inBufLength)
28 inRate->mSampleRate = inSampleRate;
29 inRate->mSampleDur = 1. / inRate->mSampleRate;
30 inRate->mRadiansPerSample = twopi / inRate->mSampleRate;
32 inRate->mBufLength = inBufLength;
33 inRate->mBufDuration = inRate->mBufLength / inRate->mSampleRate;
34 inRate->mBufRate = 1. / inRate->mBufDuration;
35 inRate->mSlopeFactor = 1. / inRate->mBufLength;
36 inRate->mFilterLoops = inRate->mBufLength / 3;
37 inRate->mFilterRemain = inRate->mBufLength % 3;
38 if( inRate->mFilterLoops == 0. )
39 inRate->mFilterSlope = 0.;
40 else
41 inRate->mFilterSlope = 1. / inRate->mFilterLoops;