adsr; fix dumb aliasing
parent
26a2bf4e82
commit
b57974e066
|
@ -14,7 +14,7 @@ namespace Xybrid::NodeLib {
|
|||
|
||||
inline Data::AudioFrame resamp(Data::Sample* smp, double pos) {
|
||||
double ip = std::floor(pos);
|
||||
auto& pt = NodeLib::resamplerLUT[static_cast<size_t>(pos - ip*NodeLib::LUT_STEPS) % NodeLib::LUT_STEPS];
|
||||
auto& pt = NodeLib::resamplerLUT[static_cast<size_t>((pos - ip)*NodeLib::LUT_STEPS) % NodeLib::LUT_STEPS];
|
||||
|
||||
Data::AudioFrame out(0.0);
|
||||
|
||||
|
|
|
@ -63,11 +63,11 @@ void Capaxitor::init() {
|
|||
addPort(Port::Input, Port::Command, 0);
|
||||
addPort(Port::Output, Port::Audio, 0);
|
||||
|
||||
core.onNoteOn = [](Note& note) {
|
||||
core.onNoteOn = [this](Note& note) {
|
||||
auto& data = *reinterpret_cast<NoteData*>(¬e.scratch);
|
||||
new (&data) NoteData(); // construct in-place
|
||||
|
||||
note.adsr = {0.0, 0.0, 1.0, shortStep}; // minimal tweening
|
||||
note.adsr = adsr;
|
||||
};
|
||||
|
||||
core.onDeleteNote = [](Note& note) {
|
||||
|
@ -114,15 +114,15 @@ void Capaxitor::saveData(QCborMap& m) const {
|
|||
m[qs("sample")] = QCborValue(smp->uuid);
|
||||
smp->markForExport();
|
||||
}
|
||||
m[qs("adsr")] = adsr;
|
||||
}
|
||||
|
||||
void Capaxitor::loadData(const QCborMap& m) {
|
||||
auto id = m.value("sample").toUuid();
|
||||
if (auto f = project->samples.find(id); f != project->samples.end()) {
|
||||
smp = f.value();
|
||||
//c->start = m.value("start").toInteger(-1);
|
||||
//c->end = m.value("end").toInteger(-1);
|
||||
}
|
||||
adsr = m.value("adsr");
|
||||
}
|
||||
|
||||
void Capaxitor::onGadgetCreated() {
|
||||
|
@ -130,7 +130,11 @@ void Capaxitor::onGadgetCreated() {
|
|||
|
||||
auto l = new LayoutGadget(obj);
|
||||
auto sampleSelector = new SampleSelectorGadget(project, l);
|
||||
sampleSelector->setSize(128, 48);
|
||||
sampleSelector->setSample(smp.lock(), false);
|
||||
|
||||
KnobGadget::autoCreate(l, adsr);
|
||||
|
||||
QObject::connect(sampleSelector, &SampleSelectorGadget::sampleSelected, [=](auto smp) { this->smp = smp; });
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ namespace Xybrid::Instruments {
|
|||
|
||||
std::weak_ptr<Data::Sample> smp = std::weak_ptr<Data::Sample>();
|
||||
|
||||
NodeLib::ADSR adsr;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue