4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005 - 2008 Christian Schoenebeck * |
* Copyright (C) 2005 - 2008 Christian Schoenebeck * |
7 |
* Copyright (C) 2009 - 2011 Christian Schoenebeck and Grigor Iliev * |
* Copyright (C) 2009 - 2012 Christian Schoenebeck and Grigor Iliev * |
8 |
* * |
* * |
9 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
10 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
76 |
ri.Pan = pRegion->Pan; |
ri.Pan = pRegion->Pan; |
77 |
ri.SampleStartOffset = pRegion->SampleStartOffset; |
ri.SampleStartOffset = pRegion->SampleStartOffset; |
78 |
|
|
|
ri.EG1PreAttack = pRegion->EG1PreAttack; |
|
|
ri.EG1Attack = pRegion->EG1Attack; |
|
|
ri.EG1Hold = pRegion->EG1Hold; |
|
|
ri.EG1Decay1 = pRegion->EG1Decay1; |
|
|
ri.EG1Decay2 = pRegion->EG1Decay2; |
|
|
ri.EG1Sustain = pRegion->EG1Sustain; |
|
|
ri.EG1InfiniteSustain = pRegion->EG1InfiniteSustain; |
|
|
ri.EG1Release = pRegion->EG1Release; |
|
|
|
|
79 |
ri.EG2PreAttack = pRegion->EG2PreAttack; |
ri.EG2PreAttack = pRegion->EG2PreAttack; |
80 |
ri.EG2Attack = pRegion->EG2Attack; |
ri.EG2Attack = pRegion->EG2Attack; |
81 |
ri.EG2Decay1 = pRegion->EG2Decay1; |
ri.EG2Decay1 = pRegion->EG2Decay1; |
443 |
} |
} |
444 |
|
|
445 |
void Voice::TriggerEG1(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) { |
void Voice::TriggerEG1(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) { |
446 |
EG1.trigger(uint(RgnInfo.EG1PreAttack), |
EG1.trigger(pRegion->EG1PreAttack, |
447 |
RgnInfo.EG1Attack * egInfo.Attack, |
pRegion->EG1Attack * egInfo.Attack, |
448 |
RgnInfo.EG1Hold, |
pRegion->EG1Hold, |
449 |
RgnInfo.EG1Decay1 * egInfo.Decay * velrelease, |
pRegion->EG1Decay1 * egInfo.Decay * velrelease, |
450 |
RgnInfo.EG1Decay2 * egInfo.Decay * velrelease, |
pRegion->EG1Decay2 * egInfo.Decay * velrelease, |
451 |
RgnInfo.EG1InfiniteSustain, |
pRegion->EG1InfiniteSustain, |
452 |
uint(RgnInfo.EG1Sustain), |
pRegion->EG1Sustain, |
453 |
RgnInfo.EG1Release * egInfo.Release * velrelease, |
pRegion->EG1Release * egInfo.Release * velrelease, |
454 |
velocityAttenuation, |
velocityAttenuation, |
455 |
sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
456 |
} |
} |
474 |
// TODO: The SustainPedal condition could be wrong, maybe the |
// TODO: The SustainPedal condition could be wrong, maybe the |
475 |
// check should be if this Voice is in release stage or is a |
// check should be if this Voice is in release stage or is a |
476 |
// release sample instead. Need to test this in GSt. |
// release sample instead. Need to test this in GSt. |
477 |
if (itEvent->Param.Note.Key != MIDIKey || |
// -- Andreas |
478 |
!GetGigEngineChannel()->SustainPedal) { |
// |
479 |
|
// Commented sustain pedal check out. I don't think voices of the same |
480 |
|
// note should be stopped at all, because it doesn't sound naturally |
481 |
|
// with a drumkit. |
482 |
|
// -- Christian, 2013-01-08 |
483 |
|
if (itEvent->Param.Note.Key != MIDIKey /*|| |
484 |
|
!GetGigEngineChannel()->SustainPedal*/) { |
485 |
dmsg(4,("Voice %x - kill", this)); |
dmsg(4,("Voice %x - kill", this)); |
486 |
|
|
487 |
// kill the voice fast |
// kill the voice fast |
489 |
} |
} |
490 |
} |
} |
491 |
|
|
492 |
|
void Voice::CalculateFadeOutCoeff(float FadeOutTime, float SampleRate) { |
493 |
|
EG1.CalculateFadeOutCoeff(FadeOutTime, SampleRate); |
494 |
|
} |
495 |
|
|
496 |
|
int Voice::CalculatePan(uint8_t pan) { |
497 |
|
int p; |
498 |
|
// Gst behaviour: -64 and 63 are special cases |
499 |
|
if (RgnInfo.Pan == -64) p = pan * 2 - 127; |
500 |
|
else if (RgnInfo.Pan == 63) p = pan * 2; |
501 |
|
else p = pan + RgnInfo.Pan; |
502 |
|
|
503 |
|
if (p < 0) return 0; |
504 |
|
if (p > 127) return 127; |
505 |
|
return p; |
506 |
|
} |
507 |
|
|
508 |
}} // namespace LinuxSampler::gig |
}} // namespace LinuxSampler::gig |