1 #ifndef __AMUSE_AUDIOGROUPPOOL_HPP__ 2 #define __AMUSE_AUDIOGROUPPOOL_HPP__ 7 #include <unordered_map> 15 static inline double TimeCentsToSeconds(int32_t tc)
19 return std::exp2(tc / (1200.0 * 65536.0));
30 uint8_t sustainCoarse;
32 uint8_t releaseCoarse;
34 double getAttack()
const {
return (attackCoarse * 255 + attackFine) / 1000.0;}
35 double getDecay()
const {
return decayCoarse == 128 ? 0.0 : ((decayCoarse * 255 + decayFine) / 1000.0);}
36 double getSustain()
const {
return decayCoarse == 128 ? 1.0 : ((sustainCoarse * 6.25 + sustainFine * 0.0244) / 100.0);}
37 double getRelease()
const {
return (releaseCoarse * 255 + releaseFine) / 1000.0;}
50 double getAttack()
const {
return TimeCentsToSeconds(attack);}
51 double getDecay()
const {
return TimeCentsToSeconds(decay);}
52 double getSustain()
const {
return sustain / double(0x1000);}
53 double getRelease()
const {
return release / double(1000);}
54 double getVelToAttack(int8_t vel)
const 56 if (velToAttack == 0x80000000)
58 return getAttack() + vel * (velToAttack / 65536.0 / 1000.0) / 128.0;
60 double getKeyToDecay(int8_t note)
const 62 if (keyToDecay == 0x80000000)
64 return getDecay() + note * (keyToDecay / 65536.0 / 1000.0) / 128.0;
95 std::unordered_map<ObjectId, const unsigned char*> m_soundMacros;
96 std::unordered_map<ObjectId, const unsigned char*> m_tables;
97 std::unordered_map<ObjectId, const Keymap*> m_keymaps;
98 std::unordered_map<ObjectId, std::vector<const LayerMapping*>> m_layers;
101 const unsigned char* soundMacro(ObjectId
id)
const;
102 const Keymap* keymap(ObjectId
id)
const;
103 const std::vector<const LayerMapping*>* layer(ObjectId
id)
const;
104 const ADSR* tableAsAdsr(ObjectId
id)
const;
105 const ADSRDLS* tableAsAdsrDLS(ObjectId
id)
const 106 {
return reinterpret_cast<const ADSRDLS*
>(tableAsAdsr(
id));}
107 const Curve* tableAsCurves(ObjectId
id)
const 108 {
return reinterpret_cast<const Curve*
>(tableAsAdsr(
id));}
113 #endif // __AMUSE_AUDIOGROUPPOOL_HPP__