| 1 |
/* |
| 2 |
* Copyright (C) 2019-2022 Rerrah |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person |
| 5 |
* obtaining a copy of this software and associated documentation |
| 6 |
* files (the "Software"), to deal in the Software without |
| 7 |
* restriction, including without limitation the rights to use, |
| 8 |
* copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 |
* copies of the Software, and to permit persons to whom the |
| 10 |
* Software is furnished to do so, subject to the following |
| 11 |
* conditions: |
| 12 |
* |
| 13 |
* The above copyright notice and this permission notice shall be |
| 14 |
* included in all copies or substantial portions of the Software. |
| 15 |
* |
| 16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 17 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
| 18 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 19 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 20 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 21 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 22 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 23 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 24 |
*/ |
| 25 |
|
| 26 |
#pragma once |
| 27 |
|
| 28 |
#include <string> |
| 29 |
#include "step.hpp" |
| 30 |
#include "bamboo_tracker_defs.hpp" |
| 31 |
|
| 32 |
enum class EffectType |
| 33 |
{ |
| 34 |
NoEffect, |
| 35 |
Arpeggio, PortamentoUp, PortamentoDown, TonePortamento, Vibrato, Tremolo, Pan, VolumeSlide, PositionJump, |
| 36 |
SongEnd, PatternBreak, SpeedTempoChange, NoteDelay, Groove, Detune, NoteSlideUp, NoteSlideDown, |
| 37 |
NoteRelease, TransposeDelay, MasterVolume, VolumeDelay, ToneNoiseMix, NoisePitch, HardEnvHighPeriod, |
| 38 |
HardEnvLowPeriod, AutoEnvelope, FBControl, TLControl, MLControl, ARControl, DRControl, RRControl, |
| 39 |
RegisterAddress0, RegisterAddress1, RegisterValue, Brightness, FineDetune, NoteCut, Retrigger, XVolumeSlide |
| 40 |
}; |
| 41 |
|
| 42 |
struct Effect |
| 43 |
{ |
| 44 |
EffectType type; |
| 45 |
int value; |
| 46 |
}; |
| 47 |
|
| 48 |
namespace effect_utils |
| 49 |
{ |
| 50 |
EffectType validateEffectId(SoundSource src, const std::string& id); |
| 51 |
Effect validateEffect(SoundSource src, const std::string& id, int value); |
| 52 |
inline Effect validateEffect(SoundSource src, const Step::PlainEffect& plain) |
| 53 |
{ |
| 54 |
return validateEffect(src, plain.id, plain.value); |
| 55 |
} |
| 56 |
|
| 57 |
inline int reverseFmVolume(int volume, bool over0 = false) noexcept |
| 58 |
{ |
| 59 |
return (volume < bt_defs::NSTEP_FM_VOLUME) ? (bt_defs::NSTEP_FM_VOLUME - 1 - volume) |
| 60 |
: over0 ? 0 : volume; |
| 61 |
} |
| 62 |
|
| 63 |
inline int reverseFmBrightness(int value) noexcept |
| 64 |
{ |
| 65 |
return (value > 0) ? (0xff - value + 1) : value; |
| 66 |
} |
| 67 |
} |