Skip to content

Commit

Permalink
Merge pull request #297 from KyleJ61782/add_cda_volume_config
Browse files Browse the repository at this point in the history
Added ability to change CD audio volume in config
  • Loading branch information
aperezbios authored Sep 14, 2023
2 parents caa34d9 + 400f886 commit e5332e4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/ZuluSCSI_platform_RP2040/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ static audio_status_code audio_last_status[8] = {ASC_NO_STATUS};

// volume information for targets
static volatile uint16_t volumes[8] = {
DEFAULT_VOLUME_LEVEL, DEFAULT_VOLUME_LEVEL, DEFAULT_VOLUME_LEVEL, DEFAULT_VOLUME_LEVEL,
DEFAULT_VOLUME_LEVEL, DEFAULT_VOLUME_LEVEL, DEFAULT_VOLUME_LEVEL, DEFAULT_VOLUME_LEVEL
DEFAULT_VOLUME_LEVEL_2CH, DEFAULT_VOLUME_LEVEL_2CH, DEFAULT_VOLUME_LEVEL_2CH, DEFAULT_VOLUME_LEVEL_2CH,
DEFAULT_VOLUME_LEVEL_2CH, DEFAULT_VOLUME_LEVEL_2CH, DEFAULT_VOLUME_LEVEL_2CH, DEFAULT_VOLUME_LEVEL_2CH
};
static volatile uint16_t channels[8] = {
AUDIO_CHANNEL_ENABLE_MASK, AUDIO_CHANNEL_ENABLE_MASK, AUDIO_CHANNEL_ENABLE_MASK, AUDIO_CHANNEL_ENABLE_MASK,
Expand Down
4 changes: 3 additions & 1 deletion src/ZuluSCSI_audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
* This implementation uses the high byte for output port 1 and the low byte
* for port 0. The two values are averaged to determine final volume level.
*/
#define DEFAULT_VOLUME_LEVEL 0x3F3F
#define DEFAULT_VOLUME_LEVEL 0x3F
#define DEFAULT_VOLUME_LEVEL_2CH DEFAULT_VOLUME_LEVEL << 8 | DEFAULT_VOLUME_LEVEL

/*
* Defines the 'enable' masks for the two audio output ports of each device.
* If this mask is matched with audio_get_channel() the relevant port will
Expand Down
8 changes: 8 additions & 0 deletions src/ZuluSCSI_disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#include "ZuluSCSI_log.h"
#include "ZuluSCSI_config.h"
#include "ZuluSCSI_presets.h"
#ifdef ENABLE_AUDIO_OUTPUT
#include "ZuluSCSI_audio.h"
#endif
#include "ZuluSCSI_cdrom.h"
#include "ImageBackingStore.h"
#include "ROMDrive.h"
Expand Down Expand Up @@ -572,6 +575,11 @@ static void scsiDiskLoadConfig(int target_idx, const char *section)
img.reinsert_on_inquiry = ini_getbool(section, "ReinsertCDOnInquiry", img.reinsert_on_inquiry, CONFIGFILE);
img.reinsert_after_eject = ini_getbool(section, "ReinsertAfterEject", img.reinsert_after_eject, CONFIGFILE);
img.ejectButton = ini_getl(section, "EjectButton", 0, CONFIGFILE);
#ifdef ENABLE_AUDIO_OUTPUT
uint16_t vol = ini_getl(section, "CDAVolume", DEFAULT_VOLUME_LEVEL, CONFIGFILE) & 0xFF;
// Set volume on both channels
audio_set_volume(target_idx, (vol << 8) | vol);
#endif

char tmp[32];
memset(tmp, 0, sizeof(tmp));
Expand Down

0 comments on commit e5332e4

Please sign in to comment.