| 31 | |
| 32 | |
| 33 | vibratingString::vibratingString( float _pitch, |
| 34 | float _pick, |
| 35 | float _pickup, |
| 36 | float * _impulse, |
| 37 | int _len, |
| 38 | sample_rate_t _sample_rate, |
| 39 | int _oversample, |
| 40 | float _randomize, |
| 41 | float _string_loss, |
| 42 | float _detune, |
| 43 | bool _state ) : |
| 44 | m_oversample( 2 * _oversample / (int)( _sample_rate / |
| 45 | Engine::mixer()->baseSampleRate() ) ), |
| 46 | m_randomize( _randomize ), |
| 47 | m_stringLoss( 1.0f - _string_loss ), |
| 48 | m_state( 0.1f ) |
| 49 | { |
| 50 | m_outsamp = new sample_t[m_oversample]; |
| 51 | int string_length; |
| 52 | |
| 53 | string_length = static_cast<int>( m_oversample * _sample_rate / |
| 54 | _pitch ) + 1; |
| 55 | string_length += static_cast<int>( string_length * -_detune ); |
| 56 | |
| 57 | int pick = static_cast<int>( ceil( string_length * _pick ) ); |
| 58 | |
| 59 | if( not _state ) |
| 60 | { |
| 61 | m_impulse = new float[string_length]; |
| 62 | resample( _impulse, _len, string_length ); |
| 63 | } |
| 64 | else |
| 65 | { |
| 66 | m_impulse = new float[_len]; |
| 67 | for( int i = 0; i < _len; i++ ) |
| 68 | { |
| 69 | m_impulse[i] = _impulse[i]; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | m_toBridge = vibratingString::initDelayLine( string_length, pick ); |
| 74 | m_fromBridge = vibratingString::initDelayLine( string_length, pick ); |
| 75 | |
| 76 | |
| 77 | vibratingString::setDelayLine( m_toBridge, pick, |
| 78 | m_impulse, _len, 0.5f, |
| 79 | _state ); |
| 80 | vibratingString::setDelayLine( m_fromBridge, pick, |
| 81 | m_impulse, _len, 0.5f, |
| 82 | _state); |
| 83 | |
| 84 | m_choice = static_cast<int>( m_oversample * |
| 85 | static_cast<float>( rand() ) / RAND_MAX ); |
| 86 | |
| 87 | m_pickupLoc = static_cast<int>( _pickup * string_length ); |
| 88 | } |
| 89 | |
| 90 |
nothing calls this directly
no test coverage detected