Skip to content

Commit

Permalink
Reset also resets busses
Browse files Browse the repository at this point in the history
Reset reset the parts but not the mixer. Fix that. Closes #1124
Also fix a multi load problem which ASAN caught reading beyond a chunk
in a string construction.
  • Loading branch information
baconpaul committed Aug 17, 2024
1 parent b8c3e5a commit 44758f0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/engine/bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ struct Bus : MoveableOnly<Bus>, SampleRateSupport
assert(address != DEFAULT_BUS && address != ERROR_BUS);
}

void resetBus()
{
busSendStorage = BusSendStorage();
for (int i = 0; i < maxEffectsPerBus; ++i)
{
busEffectStorage[i] = BusEffectStorage();
busEffects[i].reset();
}
}

float output alignas(16)[2][blockSize];
float outputOS alignas(16)[2][blockSize << 1];
bool hasOSSignal{false}, previousHadOSSignal{false};
Expand Down
7 changes: 6 additions & 1 deletion src/engine/patch.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,24 @@ struct Patch : MoveableOnly<Patch>, SampleRateSupport
// TODO - does this really belong in the patch? I think it probably does
struct Busses
{
Busses() : mainBus(MAIN_0)
Busses() : mainBus(MAIN_0) { initialize(); }
void initialize()
{
std::fill(partToVSTRouting.begin(), partToVSTRouting.end(), 0);
std::fill(auxToVSTRouting.begin(), auxToVSTRouting.end(), 0);
int adr = PART_0;
mainBus.resetBus();
for (auto &p : partBusses)
{
p.resetBus();
p.address = (BusAddress)adr;
p.busSendStorage.supportsSends = true;
adr++;
}
adr = AUX_0;
for (auto &p : auxBusses)
{
p.resetBus();
p.address = (BusAddress)adr;
adr++;
}
Expand Down Expand Up @@ -168,6 +172,7 @@ struct Patch : MoveableOnly<Patch>, SampleRateSupport
parts[i] = std::make_unique<Part>(i);
parts[i]->parentPatch = this;
}
busses.initialize();
setSampleRate(1);
}

Expand Down
2 changes: 1 addition & 1 deletion src/patch_io/patch_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void addSCManifest(const std::unique_ptr<RIFF::File> &f, const std::string &type
std::unordered_map<std::string, std::string> readSCManifest(const std::unique_ptr<RIFF::File> &f)
{
auto c1 = f->GetSubChunk('scmf');
std::string s((char *)c1->LoadChunkData());
std::string s((char *)c1->LoadChunkData(), c1->GetSize());

tao::json::events::transformer<tao::json::events::to_basic_value<json::scxt_traits>> consumer;
tao::json::events::from_string(consumer, s);
Expand Down

0 comments on commit 44758f0

Please sign in to comment.