Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for muting samples #45

Merged
merged 2 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions doc/en/sidplayfp.pod
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ Mute a channel. May be used more than one time. Channel 1 to 3
are for the first SID chip while channels from 4 to 6 are for
the second one and 7 to 9 for the third.

=item B<-g>I<< <num> >>

Mute samples. May be used more than one time, 1 for the first
SID, 2 for the second one and 3 for the third.

=item B<-p>I<< <num> >>

Set bit precision for file saving. The default is 16
Expand Down Expand Up @@ -208,6 +213,10 @@ Run with no audio output device and no sid emulation.

Mute/unmute voice.

=item q,w,e

Mute/unmute samples.

=item f

Toggle filter.
Expand Down
18 changes: 17 additions & 1 deletion src/args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,20 @@ int ConsolePlayer::args(int argc, const char *argv[])
}
}

#ifdef FEAT_SAMPLE_MUTE
// Sample muting
else if (argv[i][1] == 'g')
{
if (argv[i][2] == '\0')
err = true;
else
{
const int chip = atoi(&argv[i][2]);
if (chip > 0 && chip <= m_mute_samples.size())
m_mute_samples[chip-1] = true;
}
}
#endif
else if (argv[i][1] == 'p')
{ // User forgot precision
if (argv[i][2] == '\0')
Expand Down Expand Up @@ -634,7 +648,9 @@ void ConsolePlayer::displayArgs (const char *arg)
#endif

<< " -u<num> mute voice <num> (e.g. -u1 -u2)" << endl

#ifdef FEAT_SAMPLE_MUTE
<< " -g<num> mute samples <num> (e.g. -g1 -g2)" << endl
#endif
<< " -nf no SID filter emulation" << endl

<< " -o<l|s>[num] looping and/or single track" << endl
Expand Down
5 changes: 5 additions & 0 deletions src/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ static char keytable[] =
'7',0, A_TOGGLE_VOICE7,
'8',0, A_TOGGLE_VOICE8,
'9',0, A_TOGGLE_VOICE9,
#ifdef FEAT_SAMPLE_MUTE
'q',0, A_TOGGLE_SAMPLE1,
'w',0, A_TOGGLE_SAMPLE2,
'e',0, A_TOGGLE_SAMPLE3,
#endif
'f',0, A_TOGGLE_FILTER,

// General Keys
Expand Down
7 changes: 7 additions & 0 deletions src/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include "sidlib_features.h"

#ifdef _WIN32
# include <conio.h>
#else
Expand Down Expand Up @@ -55,6 +57,11 @@ enum
A_TOGGLE_VOICE7,
A_TOGGLE_VOICE8,
A_TOGGLE_VOICE9,
#ifdef FEAT_SAMPLE_MUTE
A_TOGGLE_SAMPLE1,
A_TOGGLE_SAMPLE2,
A_TOGGLE_SAMPLE3,
#endif
A_TOGGLE_FILTER
};

Expand Down
20 changes: 19 additions & 1 deletion src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,11 @@ bool ConsolePlayer::open (void)
m_engine.mute(2, 0, m_mute_channel[6]);
m_engine.mute(2, 1, m_mute_channel[7]);
m_engine.mute(2, 2, m_mute_channel[8]);
#ifdef FEAT_SAMPLE_MUTE
m_engine.mute(0, 3, m_mute_samples[0]);
m_engine.mute(1, 3, m_mute_samples[1]);
m_engine.mute(2, 3, m_mute_samples[2]);
#endif

// As yet we don't have a required songlength
// so try the songlength database or keep the default
Expand Down Expand Up @@ -1192,7 +1197,20 @@ void ConsolePlayer::decodeKeys ()
m_mute_channel.flip(8);
m_engine.mute(2, 2, m_mute_channel[8]);
break;

#ifdef FEAT_SAMPLE_MUTE
case A_TOGGLE_SAMPLE1:
m_mute_samples.flip(0);
m_engine.mute(0, 3, m_mute_samples[0]);
break;
case A_TOGGLE_SAMPLE2:
m_mute_samples.flip(1);
m_engine.mute(1, 3, m_mute_samples[1]);
break;
case A_TOGGLE_SAMPLE3:
m_mute_samples.flip(2);
m_engine.mute(2, 3, m_mute_samples[2]);
break;
#endif
case A_TOGGLE_FILTER:
m_filter.enabled = !m_filter.enabled;
m_engCfg.sidEmulation->filter(m_filter.enabled);
Expand Down
3 changes: 3 additions & 0 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ class ConsolePlayer
bool m_autofilter;

std::bitset<9> m_mute_channel;
#ifdef FEAT_SAMPLE_MUTE
std::bitset<3> m_mute_samples;
#endif

int m_channels;
int m_precision;
Expand Down
4 changes: 4 additions & 0 deletions src/sidlib_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@
# define FEAT_CW_STRENGTH
#endif

#if LIBSIDPLAYFP_VERSION_MAJ > 2 || (LIBSIDPLAYFP_VERSION_MAJ == 2 && LIBSIDPLAYFP_VERSION_MIN >= 10)
# define FEAT_SAMPLE_MUTE
#endif

#endif
Loading