Skip to content

Commit

Permalink
默认禁用 使用设备能处理的最大声道数输出音频 设置,修复高级音频API与自定义音频输出设备功能冲突的提示显示
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed May 2, 2024
1 parent 6933baa commit ee6a6f4
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 25 deletions.
3 changes: 1 addition & 2 deletions publish/changeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### 新增

- 新增 设置-播放设置-使用设备能处理的最大声道数输出音频 设置并默认启用#1873
- 新增 设置-播放设置-使用设备能处理的最大声道数输出音频 设置(未启用时固定为2声道输出),由于这用到高级音频API,考虑到在某些设备上的兼容问题,默认禁用#1873
- 允许添加 `m4a``oga` 格式的本地歌曲到列表中(#1864
- 开放API支持跨域请求(#1872 @Ceale

Expand All @@ -21,7 +21,6 @@
### 变更

- 设置-播放设置-优先播放320k音质选项改为“优先播放的音质”,允许选择更高优先播放的音质,如果歌曲及音源支持的话(#1839
- 设置-播放设置-使用设备能处理的最大声道数输出音频 设置默认启用,此前固定为2声道输出

### 开放API变更

Expand Down
2 changes: 1 addition & 1 deletion src/common/defaultSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const defaultSetting: LX.AppSetting = {
'player.isMute': false,
'player.playbackRate': 1,
'player.preservesPitch': true,
'player.isMaxOutputChannelCount': true,
'player.isMaxOutputChannelCount': false,
'player.mediaDeviceId': 'default',
'player.isMediaDeviceRemovedStopPlay': false,
'player.isShowLyricTranslation': false,
Expand Down
5 changes: 3 additions & 2 deletions src/lang/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@
"setting__other_tray_theme_native": "White",
"setting__other_tray_theme_origin": "Primary Color",
"setting__play": "Play",
"setting__play_advanced_audio_features_tip": "A custom audio output device conflicts with this function. After enabling this function, the audio output device will be reset to the default output device. This problem cannot be solved at the moment. Do you still want to enable it?",
"setting__play_auto_clean_played_list": "Whether to clear the existing playlist when clicking the same list as the playlist to switch songs (all songs in the list in random mode will participate in the random again)",
"setting__play_auto_skip_on_error": "Automatically switch songs on playback error",
"setting__play_detail": "Play details page settings",
Expand All @@ -517,8 +518,8 @@
"setting__play_mediaDevice": "Audio output",
"setting__play_mediaDevice_remove_stop_play": "Pause the song when the current sound output device is changed",
"setting__play_mediaDevice_title": "Select a media device for audio output",
"setting__play_media_device_error_tip": "This function conflicts with advanced audio functions (audio visualization, sound effect settings). These functions have been enabled when you start the software this time. This setting is not available for now. Please close these functions and restart the software before modifying this setting.",
"setting__play_media_device_tip": "This feature conflicts with Audio Visualization, both cannot be enabled at the same time, would you like to turn Audio Visualization off and apply the selected audio output settings?",
"setting__play_media_device_error_tip": "This feature conflicts with advanced audio features (audio visualization, sound effect settings, audio output using the maximum number of channels that the device can handle). You have enabled these features when you started the software this time. This setting is temporarily unavailable. Please turn off these features and After restarting the software, modify this setting again.",
"setting__play_media_device_tip": "This feature conflicts with the audio visualization feature and cannot be enabled at the same time. Do you want to turn audio visualization off and apply the selected audio output settings?",
"setting__play_playQuality": "Prioritize sound quality for playback (if available)",
"setting__play_power_save_blocker": "Prevent computer from sleeping while playing songs",
"setting__play_save_play_time": "Remember playback progress",
Expand Down
4 changes: 3 additions & 1 deletion src/lang/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
"player__sound_effect_convolution_file_tim_omni_35_10_magnetic": "磁性立体声",
"player__sound_effect_convolution_main_gain": "原始音频增益",
"player__sound_effect_convolution_send_gain": "环境音效增益",
"player__sound_effect_features_tip": "提示:音效功能 与 自定义音频输出设备功能 冲突,启用音效功能后音频输出设备将会被重置为默认的输出设备,目前此问题暂无法解决。",
"player__sound_effect_panner": "3D立体环绕(需使用耳机)",
"player__sound_effect_panner_enabled": "启用",
"player__sound_effect_panner_sound_r": "声音距离",
Expand Down Expand Up @@ -497,6 +498,7 @@
"setting__other_tray_theme_native": "白色",
"setting__other_tray_theme_origin": "原色",
"setting__play": "播放设置",
"setting__play_advanced_audio_features_tip": "自定义音频输出设备与该功能冲突,启用该功能后音频输出设备将会被重置为默认的输出设备,目前此问题暂无法解决,是否仍要开启?",
"setting__play_auto_clean_played_list": "点击与播放列表相同的列表切歌时是否清空已播放列表(随机模式下列表内所有歌曲会重新参与随机)",
"setting__play_auto_skip_on_error": "播放错误时自动切换歌曲",
"setting__play_detail": "播放详情页设置",
Expand All @@ -517,7 +519,7 @@
"setting__play_mediaDevice": "音频输出",
"setting__play_mediaDevice_remove_stop_play": "当前的声音输出设备被改变时暂停播放歌曲",
"setting__play_mediaDevice_title": "选择声音输出的媒体设备",
"setting__play_media_device_error_tip": "此功能与高级音频功能(音频可视化、音效设置)冲突,你本次启动软件时已启用这些功能,此设置暂不可用,请 关闭这些功能 并 重启 软件后,再来修改此设置。",
"setting__play_media_device_error_tip": "此功能与高级音频功能(音频可视化、音效设置、使用设备能处理的最大声道数输出音频功能)冲突,你本次启动软件时已启用这些功能,此设置暂不可用,请 关闭这些功能 并 重启 软件后,再来修改此设置。",
"setting__play_media_device_tip": "此功能与音频可视化功能冲突,两者无法同时启用,是否将音频可视化关闭 并 应用所选音频输出设置?",
"setting__play_playQuality": "优先播放的音质(如果可用)",
"setting__play_power_save_blocker": "播放歌曲时阻止电脑休眠",
Expand Down
3 changes: 2 additions & 1 deletion src/lang/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@
"setting__other_tray_theme_native": "白色",
"setting__other_tray_theme_origin": "原色",
"setting__play": "播放設定",
"setting__play_advanced_audio_features_tip": "自訂音訊輸出設備與此功能衝突,啟用該功能後音訊輸出設備將會被重設為預設的輸出設備,目前此問題暫無法解決,是否仍要開啟?",
"setting__play_auto_clean_played_list": "點選與播放清單相同的清單切歌時是否已清空已播放清單(隨機模式下清單內所有歌曲會重新參與隨機)",
"setting__play_auto_skip_on_error": "播放錯誤時自動切換歌曲",
"setting__play_detail": "播放詳情頁設定",
Expand All @@ -517,7 +518,7 @@
"setting__play_mediaDevice": "音訊輸出",
"setting__play_mediaDevice_remove_stop_play": "當前的聲音輸出裝置被改變時暫停播放歌曲",
"setting__play_mediaDevice_title": "選擇聲音輸出的媒體設備",
"setting__play_media_device_error_tip": "此功能與進階音訊功能(音訊視覺化、音效設定)衝突,你本次啟動軟體時已啟用這些功能,此設定暫不可用,請 關閉這些功能 並 重新啟動 軟體後,再來修改此設定。",
"setting__play_media_device_error_tip": "此功能與進階音訊功能(音訊視覺化、音效設定、使用裝置能處理的最大聲道數輸出音訊功能)衝突,你本次啟動軟體時已啟用這些功能,此設定暫不可用,請 關閉這些功能 並 重啟 軟體後,再來修改此設定。",
"setting__play_media_device_tip": "此功能與音訊視覺化功能衝突,兩者無法同時啟用,是否將音訊視覺化關閉 並 應用所選音訊輸出設定?",
"setting__play_playQuality": "優先播放的音質(如果可用)",
"setting__play_power_save_blocker": "播放歌曲時阻止電腦休眠",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@

<script setup>
import { ref, onMounted, computed } from '@common/utils/vueTools'
import { appSetting, updateSetting } from '@renderer/store/setting'
import { convolutions } from '@renderer/plugins/player'
import { appSetting, saveMediaDeviceId, updateSetting } from '@renderer/store/setting'
import { convolutions, setMediaDeviceId } from '@renderer/plugins/player'
import AddConvolutionPresetBtn from './AddConvolutionPresetBtn.vue'
import { getUserConvolutionPresetList, removeUserConvolutionPreset } from '@renderer/store/soundEffect'
const updateConvolution = val => {
const updateConvolution = async val => {
if (appSetting['player.mediaDeviceId'] != 'default') {
await setMediaDeviceId('default').catch(_ => _)
saveMediaDeviceId('default')
}
const target = convolutions.find(c => c.source == val)
const setting = {
'player.soundEffect.convolution.fileName': val,
Expand All @@ -61,6 +65,7 @@ const handleUpdateSendGain = (value) => {
}
const handleSetPreset = (item) => {
if (appSetting['player.mediaDeviceId'] != 'default') saveMediaDeviceId('default')
updateSetting({
'player.soundEffect.convolution.fileName': item.source,
'player.soundEffect.convolution.mainGain': item.mainGain,
Expand Down
9 changes: 7 additions & 2 deletions src/renderer/components/common/SoundEffectBtn/AudioPanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,21 @@

<script setup>
// import { reactive } from '@common/utils/vueTools'
import { appSetting, updateSetting } from '@renderer/store/setting'
import { setMediaDeviceId } from '@renderer/plugins/player'
import { appSetting, saveMediaDeviceId, updateSetting } from '@renderer/store/setting'
// const setting = reactive({
// enabled: false,
// soundR: 5,
// speed: 25,
// })
const updateEnabled = (enabled) => {
const updateEnabled = async(enabled) => {
// console.log(enabled)
if (appSetting['player.mediaDeviceId'] != 'default') {
await setMediaDeviceId('default').catch(_ => _)
saveMediaDeviceId('default')
}
updateSetting({ 'player.soundEffect.panner.enable': enabled })
}
Expand Down
11 changes: 8 additions & 3 deletions src/renderer/components/common/SoundEffectBtn/BiquadFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@

<script setup>
import { onMounted, ref } from '@common/utils/vueTools'
import { freqs, freqsPreset } from '@renderer/plugins/player'
import { appSetting, updateSetting } from '@renderer/store/setting'
import { freqs, freqsPreset, setMediaDeviceId } from '@renderer/plugins/player'
import { appSetting, saveMediaDeviceId, updateSetting } from '@renderer/store/setting'
import AddEQPresetBtn from './AddEQPresetBtn.vue'
import { getUserEQPresetList, removeUserEQPreset } from '@renderer/store/soundEffect'
const labels = freqs.map(num => num < 1000 ? num : `${num / 1000}k`)
const handleUpdate = (key, value) => {
const handleUpdate = async(key, value) => {
if (appSetting['player.mediaDeviceId'] != 'default') {
await setMediaDeviceId('default').catch(_ => _)
saveMediaDeviceId('default')
}
value = Math.round(value)
// values[index] = value
updateSetting({ [`player.soundEffect.biquadFilter.hz${key}`]: value })
Expand Down
11 changes: 8 additions & 3 deletions src/renderer/components/common/SoundEffectBtn/PitchShifter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

<script setup>
import { computed } from '@common/utils/vueTools'
import { appSetting, updateSetting } from '@renderer/store/setting'
import { setMediaDeviceId } from '@renderer/plugins/player'
import { appSetting, saveMediaDeviceId, updateSetting } from '@renderer/store/setting'
// import AddPitchShifterPresetBtn from './AddPitchShifterPresetBtn.vue'
// import { getUserPitchShifterPresetList, removeUserPitchShifterPreset } from '@renderer/store/soundEffect'
// import { semitones } from '@renderer/plugins/player'
Expand All @@ -37,7 +38,11 @@ import { appSetting, updateSetting } from '@renderer/store/setting'
const playbackRate = computed(() => appSetting['player.soundEffect.pitchShifter.playbackRate'])
const handleSetPreset = (value) => {
const handleSetPreset = async(value) => {
if (appSetting['player.mediaDeviceId'] != 'default') {
await setMediaDeviceId('default').catch(_ => _)
saveMediaDeviceId('default')
}
updateSetting({ 'player.soundEffect.pitchShifter.playbackRate': value })
}
Expand All @@ -48,7 +53,7 @@ const handleSetPreset = (value) => {
const handleUpdatePlaybackRate = (value) => {
value = parseFloat((Math.round(value) / 100).toFixed(2))
handleSetPreset(value)
void handleSetPreset(value)
}
Expand Down
18 changes: 17 additions & 1 deletion src/renderer/components/common/SoundEffectBtn/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
<BiquadFilter />
</div>
</div>
<p v-if="showTip" :class="$style.tip">{{ $t('player__sound_effect_features_tip') }}</p>
<!-- </main> -->
</material-modal>
</template>

<script setup>
import { ref } from '@common/utils/vueTools'
import { ref, watch } from '@common/utils/vueTools'
// import useNextTogglePlay from '@renderer/utils/compositions/useNextTogglePlay'
// import useToggleDesktopLyric from '@renderer/utils/compositions/useToggleDesktopLyric'
// import { musicInfo, playMusicInfo } from '@renderer/store/player/state'
Expand All @@ -33,6 +34,7 @@ import BiquadFilter from './BiquadFilter.vue'
import AudioPanner from './AudioPanner.vue'
import AudioConvolution from './AudioConvolution.vue'
import PitchShifter from './PitchShifter.vue'
import { appSetting } from '@renderer/store/setting'
defineProps({
teleport: {
Expand All @@ -43,6 +45,12 @@ defineProps({
const visible = ref(false)
const showTip = ref(false)
watch(visible, (visible) => {
if (visible) showTip.value = appSetting['player.mediaDeviceId'] != 'default'
})
</script>

Expand Down Expand Up @@ -134,4 +142,12 @@ const visible = ref(false)
padding: 0 10px;
}
.tip {
padding: 0 15px 15px;
margin-top: 5px;
font-size: 12px;
line-height: 1.25;
color: var(--color-font);
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ export default {
confirmButtonText: t('confirm_button_text'),
})
if (!confirm) return
saveMediaDeviceId('default')
await setMediaDeviceId('default').catch(_ => _)
saveMediaDeviceId('default')
}
setEnableAudioVisualization(newSetting)
}
Expand Down
33 changes: 28 additions & 5 deletions src/renderer/views/Setting/components/SettingPlay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dd
.gap-top
base-checkbox(id="setting_player_showTaskProgess" :model-value="appSetting['player.isShowTaskProgess']" :label="$t('setting__play_task_bar')" @update:model-value="updateSetting({'player.isShowTaskProgess': $event})")
.gap-top
base-checkbox(id="setting_player_isMaxOutputChannelCount" :model-value="appSetting['player.isMaxOutputChannelCount']" :label="$t('setting__play_max_output_channel_count')" @update:model-value="updateSetting({'player.isMaxOutputChannelCount': $event})")
base-checkbox(id="setting_player_isMaxOutputChannelCount" :model-value="isMaxOutputChannelCount" :label="$t('setting__play_max_output_channel_count')" @update:model-value="handleUpdateMaxOutputChannelCount")
.gap-top
base-checkbox(id="setting_player_isMediaDeviceRemovedStopPlay" :model-value="appSetting['player.isMediaDeviceRemovedStopPlay']" :label="$t('setting__play_mediaDevice_remove_stop_play')" @update:model-value="updateSetting({'player.isMediaDeviceRemovedStopPlay': $event})")

Expand All @@ -42,10 +42,10 @@ dd(:aria-label="$t('setting__play_mediaDevice_title')")

<script>
import { ref, onBeforeUnmount, watch } from '@common/utils/vueTools'
import { hasInitedAdvancedAudioFeatures } from '@renderer/plugins/player'
import { hasInitedAdvancedAudioFeatures, setMediaDeviceId } from '@renderer/plugins/player'
import { dialog } from '@renderer/plugins/Dialog'
import { useI18n } from '@renderer/plugins/i18n'
import { appSetting, updateSetting } from '@renderer/store/setting'
import { appSetting, saveMediaDeviceId, updateSetting } from '@renderer/store/setting'
import { setPowerSaveBlocker } from '@renderer/core/player/utils'
import { isPlay } from '@renderer/store/player/state'
import { TRY_QUALITYS_LIST } from '@renderer/core/music/utils'
Expand Down Expand Up @@ -86,8 +86,10 @@ export default {
confirmButtonText: t('confirm_button_text'),
})
if (confirm) {
appSetting['player.audioVisualization'] = false
appSetting['player.mediaDeviceId'] = mediaDeviceId.value
updateSetting({
'player.audioVisualization': false,
'player.mediaDeviceId': mediaDeviceId.value,
})
} else {
mediaDeviceId.value = appSetting['player.mediaDeviceId']
}
Expand All @@ -108,6 +110,25 @@ export default {
updateSetting({ 'player.powerSaveBlocker': enabled })
}
const isMaxOutputChannelCount = ref(appSetting['player.isMaxOutputChannelCount'])
const handleUpdateMaxOutputChannelCount = async(enabled) => {
isMaxOutputChannelCount.value = enabled
if (appSetting['player.mediaDeviceId'] != 'default') {
const confirm = await dialog.confirm({
message: t('setting__play_advanced_audio_features_tip'),
cancelButtonText: t('cancel_button_text'),
confirmButtonText: t('confirm_button_text'),
})
if (!confirm) {
isMaxOutputChannelCount.value = false
return
}
await setMediaDeviceId('default').catch(_ => _)
saveMediaDeviceId('default')
}
updateSetting({ 'player.isMaxOutputChannelCount': enabled })
}
return {
appSetting,
Expand All @@ -116,6 +137,8 @@ export default {
mediaDeviceId,
handleMediaDeviceIdChnage,
handleUpdatePowerSaveBlocker,
isMaxOutputChannelCount,
handleUpdateMaxOutputChannelCount,
playQualityList,
}
},
Expand Down

0 comments on commit ee6a6f4

Please sign in to comment.