Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions src/iprojectM.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void initProjectM( VisualPluginData * visualPluginData, std::string presetPath )
std::string cfg_path = "/usr/local/share/projectM/config.inp";

// hardcoded settings - disabled
projectm_settings settings;
projectm_settings settings{};
settings.mesh_x = 140;
settings.mesh_y = 110;
settings.fps = 60;
Expand Down Expand Up @@ -103,7 +103,7 @@ void ProcessRenderData( VisualPluginData * visualPluginData, UInt32 timeStampID,

visualPluginData->renderTimeStampID = timeStampID;

if ( renderData == NULL )
if (renderData == nullptr)
{
memset( &visualPluginData->renderData, 0, sizeof(visualPluginData->renderData) );
return;
Expand All @@ -129,12 +129,22 @@ void ProcessRenderData( VisualPluginData * visualPluginData, UInt32 timeStampID,
visualPluginData->maxLevel[channel] = value;
}
}

if (pm != NULL) {
// pass waveform data to projectM
projectm_pcm_add_uint8(pm, reinterpret_cast<const uint8_t*>(renderData->waveformData[0][0]),
512, PROJECTM_STEREO);
}

if (pm == nullptr)
{
return;
}

// Interleave audio data from the two channel buffers
UInt8 interleavedData[kVisualNumWaveformEntries][kVisualMaxDataChannels];
for (auto sample = 0; sample < kVisualNumWaveformEntries; sample++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (auto sample = 0; sample < kVisualNumWaveformEntries; sample++)
for (auto sample = 0; sample < kVisualNumWaveformEntries * kVisualMaxDataChannels; sample+= kVisualMaxDataChannels)

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that would read & write twice the size of the source and destination arrays. kVisualMaxDataChannels is hard-coded to 2 in the header, so it'll never change unless we do it. That correct? Dunno, it works.

{
interleavedData[sample][0] = renderData->waveformData[0][sample];
interleavedData[sample][1] = renderData->waveformData[1][sample];
}

// pass waveform data to projectM
projectm_pcm_add_uint8(pm, &interleavedData[0][0],512, PROJECTM_STEREO);
}

//-------------------------------------------------------------------------------------------------
Expand Down