Skip to content

feat: add per-channel audio capture with OPL/FM voice isolation#35

Open
pedrocatalao wants to merge 2 commits into
OpenMPT:masterfrom
pedrocatalao:feat/channel-voice-isolation
Open

feat: add per-channel audio capture with OPL/FM voice isolation#35
pedrocatalao wants to merge 2 commits into
OpenMPT:masterfrom
pedrocatalao:feat/channel-voice-isolation

Conversation

@pedrocatalao
Copy link
Copy Markdown

Adds opt-in per-channel audio isolation for both PCM and OPL/FM synthesis paths, accessible via the "render.channel_capture" CTL.

PCM isolation: CSoundFile::CreateStereoMix() snapshots MixSoundBuffer before and after each MixChannel() call, accumulating each channel's isolated contribution in m_channelCaptureBuf.

OPL/FM isolation: Opal::Output() captures each voice's left-channel value before summation into m_voiceOut[]. OPL::Mix() reads these per-frame and stores them in m_voiceFrames[voice][frame], scaled to mix-buffer amplitude.

New public API (C and C++):
get_current_channel_audio_mono(channel, count, buf)
get_current_channel_audio_stereo(channel, count, buf_left, buf_right)

Both functions combine PCM and OPL contributions transparently, so callers do not need to know which synthesis path a channel is using. Data is valid after read() and before the next read() call.

Usage:
module.ctl_set_boolean("render.channel_capture", true);
module.read_float_mono(samplerate, count, master_out);
module.get_current_channel_audio_mono(ch, count, ch_out);

Adds opt-in per-channel audio isolation for both PCM and OPL/FM synthesis
paths, accessible via the "render.channel_capture" CTL.

PCM isolation: CSoundFile::CreateStereoMix() snapshots MixSoundBuffer
before and after each MixChannel() call, accumulating each channel's
isolated contribution in m_channelCaptureBuf.

OPL/FM isolation: Opal::Output() captures each voice's left-channel value
before summation into m_voiceOut[]. OPL::Mix() reads these per-frame and
stores them in m_voiceFrames[voice][frame], scaled to mix-buffer amplitude.

New public API (C and C++):
  get_current_channel_audio_mono(channel, count, buf)
  get_current_channel_audio_stereo(channel, count, buf_left, buf_right)

Both functions combine PCM and OPL contributions transparently, so callers
do not need to know which synthesis path a channel is using. Data is valid
after read() and before the next read() call.

Usage:
  module.ctl_set_boolean("render.channel_capture", true);
  module.read_float_mono(samplerate, count, master_out);
  module.get_current_channel_audio_mono(ch, count, ch_out);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant