Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
gvnnz committed Jul 28, 2024
1 parent 4c52689 commit 6789add
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 15 deletions.
39 changes: 35 additions & 4 deletions src/core/channels/channelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,29 @@ Channel& ChannelManager::getChannel(ID channelId)

void ChannelManager::reset(Frame framesInBuffer)
{
m_model.get().channels = {};
{
m_model.get().channels = {};

const bool overdubProtection = false;
const Resampler::Quality rsmpQuality = m_model.get().kernelAudio.rsmpQuality;

channelFactory::Data masterOutData = channelFactory::create(
Mixer::MASTER_OUT_CHANNEL_ID, ChannelType::MASTER, framesInBuffer, rsmpQuality, overdubProtection);
channelFactory::Data masterInData = channelFactory::create(
Mixer::MASTER_IN_CHANNEL_ID, ChannelType::MASTER, framesInBuffer, rsmpQuality, overdubProtection);
channelFactory::Data previewData = channelFactory::create(
Mixer::PREVIEW_CHANNEL_ID, ChannelType::PREVIEW, framesInBuffer, rsmpQuality, overdubProtection);

m_model.get().channels.add(std::move(masterOutData.channel));
m_model.get().channels.add(std::move(masterInData.channel));
m_model.get().channels.add(std::move(previewData.channel));

m_model.addChannelShared(std::move(masterOutData.shared));
m_model.addChannelShared(std::move(masterInData.shared));
m_model.addChannelShared(std::move(previewData.shared));
}

/* Create hidden column with internal channels (Master In/Out, Preview). */

const bool overdubProtection = false;
const Resampler::Quality rsmpQuality = m_model.get().kernelAudio.rsmpQuality;
Expand All @@ -80,13 +102,22 @@ void ChannelManager::reset(Frame framesInBuffer)
channelFactory::Data previewData = channelFactory::create(
Mixer::PREVIEW_CHANNEL_ID, ChannelType::PREVIEW, framesInBuffer, rsmpQuality, overdubProtection);

m_model.get().channels.add(std::move(masterOutData.channel));
m_model.get().channels.add(std::move(masterInData.channel));
m_model.get().channels.add(std::move(previewData.channel));
m_model.get().columns = {};

model::Column& column = m_model.get().columns.add(std::move(masterOutData.channel), 0, /*isInternal=*/true);
column.addChannel(std::move(masterInData.channel));
column.addChannel(std::move(previewData.channel));

m_model.addChannelShared(std::move(masterOutData.shared));
m_model.addChannelShared(std::move(masterInData.shared));
m_model.addChannelShared(std::move(previewData.shared));

/* Create visible empty column. */

channelFactory::Data groupData = channelFactory::create(/*id=*/0, ChannelType::GROUP, framesInBuffer, rsmpQuality, overdubProtection);

m_model.get().columns.add(std::move(groupData.channel), 200, /*isInternal=*/false);
m_model.addChannelShared(std::move(groupData.shared));
}

/* -------------------------------------------------------------------------- */
Expand Down
23 changes: 12 additions & 11 deletions src/glue/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,21 @@ void printLoadError_(int res)

/* -------------------------------------------------------------------------- */

Data makeData_(ID channelId, const v::Model::Column& column)
Data makeData_(ID channelId, const m::model::Column& modelColumn)
{
const int position = column.getChannelIndex(channelId);
const int columnIndex = column.index;
return Data(g_engine->getChannelsApi().get(channelId), columnIndex, position);
const std::size_t channelIndex = modelColumn.getChannelIndex(channelId);
const std::size_t columnIndex = modelColumn.getIndex();
return Data(g_engine->getChannelsApi().get(channelId), columnIndex, channelIndex);
}

/* -------------------------------------------------------------------------- */

Column makeColumn_(const v::Model::Column& modelColumn)
Column makeColumn_(const m::model::Column& modelColumn)
{
Column column{modelColumn.index, modelColumn.width, {}};
Column column{static_cast<int>(modelColumn.getIndex()), modelColumn.width, {}};

for (const ID channelId : modelColumn.channels)
column.channels.push_back(makeData_(channelId, modelColumn));
for (const m::Channel& channel : modelColumn.getChannels().getAll())
column.channels.push_back(makeData_(channel.id, modelColumn));

return column;
}
Expand Down Expand Up @@ -153,14 +153,15 @@ bool Data::isArmed() const { return g_engine->getChannelsApi().get(id).

Data getData(ID channelId)
{
return makeData_(channelId, g_ui->model.columns.getColumnByChannelId(channelId));
return makeData_(channelId, g_engine->getChannelsApi().getColumns().getByChannel(channelId));
}

std::vector<Column> getColumns()
{
std::vector<Column> out;
for (const v::Model::Column& modelColumn : g_ui->model.columns.getAll()) // Model::columns is the source of truth
out.push_back(makeColumn_(modelColumn));
for (const m::model::Column& modelColumn : g_engine->getChannelsApi().getColumns().getAll())
if (!modelColumn.isInternal())
out.push_back(makeColumn_(modelColumn));
return out;
}

Expand Down

0 comments on commit 6789add

Please sign in to comment.