/* Copyright 2012 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef SYNTH_H #define SYNTH_H //#define SUPER_PRECISE #include #define MIDI_CONTROLLER_MODE_MAX 2 #define TRANSPOSE_FIX 24 #define VOICE_SILENCE_LEVEL 1100 #define LG_N 6 #define _N_ (1 << LG_N) /*template inline static T min(const T& a, const T& b) { return a < b ? a : b; } template inline static T max(const T& a, const T& b) { return a > b ? a : b; }*/ #define QER(n,b) ( ((float)n)/(1< #ifndef M_PI #define M_PI 3.14159265358979323846 #endif #define constrain(amt, low, high) ({ \ __typeof__(amt) _amt = (amt); \ __typeof__(low) _low = (low); \ __typeof__(high) _high = (high); \ (_amt < _low) ? _low : ((_amt > _high) ? _high : _amt); \ }) static inline int32_t signed_saturate_rshift(int32_t val, int32_t bits, int32_t rshift) { int32_t out, max; out = val >> rshift; max = 1 << (bits - 1); if (out >= 0) { if (out > max - 1) out = max - 1; } else { if (out < -max) out = -max; } return out; } static inline uint32_t millis (void) { return uint32_t(CTimer::Get ()->GetClockTicks () / (CLOCKHZ / 1000)); } #endif #endif