SoundSet

サウンドデバイスの各種設定を変更

SoundSet, NewSetting [, ComponentType, ControlType, DeviceNumber]

Parameters

引数名説明
NewSetting 新しい設定を-100...100の間の数値で指定。
引数が「+」か「-」から始まる場合、現在の設定からの相対値の指定となる。
ControlTypeが「ONOFF」「MUTE」「MONO」「LOUDNESS」「STEREOENH」「BASSBOOST」の場合、正の値を指定するとONに、「0」を指定するとOFFになる。「+」や「-」で始まる値では、ON/OFFを切り替える。
ComponentType 以下のどれか。
  • MASTER(デフォルト)
  • DIGITAL
  • LINE
  • MICROPHONE
  • SYNTH
  • CD
  • TELEPHONE
  • PCSPEAKER
  • WAVE
  • AUX
  • ANALOG
  • HEADPHONES
  • N/A
デバイスが存在しない場合、ErrorLevelにその旨を示す文字列が代入される。
同じ種類のものが複数あるときは「ANALOG:2」のように指定することで、2つ目以降のデバイスを指定できる。多くの場合、1番目は入力、2番目は出力である。
ControlType
  • VOLUME(デフォルト)
  • ONOFF
  • MUTE
  • MONO
  • LOUDNESS
  • STEREOENH
  • BASSBOOST
  • PAN
  • QSOUNDPAN
  • BASS
  • TREBLE
  • EQUALIZER
数値でコントロール番号を指定することもできる。
その設定が存在しない場合、ErrorLevelにその旨を示す文字列が代入される。
DeviceNumber デバイス番号。
デフォルトは「1」

ErrorLevel

成功した場合、「0」。
何か問題があれば、以下のような文が代入される。

Remarks

現在の設定値を取得するには、SoundGetを使用する

このコマンドで音量を変更されたコンポーネントは、左右のバランスが中央に設定されてしまう。
SoundSetWaveVolumeではこの副作用は発生しない。

Related

SoundGet, SoundGetWaveVolume, SoundSetWaveVolume, SoundPlay

Example(s)

SoundSet, 50  ; Set the master volume to 50%
SoundSet +10  ; Increase master volume by 10%
SoundSet -10  ; Decrease master volume by 10%
SoundSet, 1, Microphone, mute  ; mute the microphone
SoundSet, +1, , mute  ; Toggle the master mute (set it to the opposite state)
SoundSet, +20, Master, bass  ; Increase bass level by 20%.
if ErrorLevel <> 0
	MsgBox, The BASS setting is not supported for MASTER.
;サウンドカードのすべてのコンポーネント、コントロールの設定を表示する。
; Use the following script to discover your soundcard's capabilities (component types and control types).
; This script requires v1.0.36+ because it uses a ListView.

SetBatchLines -1
SplashTextOn,,, Gathering Soundcard Info...

Component1 = MASTER
Component2 = DIGITAL
Component3 = LINE
Component4 = MICROPHONE
Component5 = SYNTH
Component6 = CD
Component7 = TELEPHONE
Component8 = PCSPEAKER
Component9 = WAVE
Component10 = AUX
Component11 = ANALOG
Component12 = N/A

Control1 = VOLUME
Control2 = ONOFF
Control3 = MUTE
Control4 = MONO
Control5 = LOUDNESS
Control6 = STEREOENH
Control7 = BASSBOOST
Control8 = PAN
Control9 = QSOUNDPAN
Control10 = BASS
Control11 = TREBLE
Control12 = EQUALIZER
; Most of the following probably don't exist in any mixer, but they're queried for completeness:
Control13 = 0x00000000  ; CUSTOM
Control14 = 0x10010000  ; BOOLEANMETER
Control15 = 0x10020000  ; SIGNEDMETER
Control16 = 0x10020001  ; PEAKMETER
Control17 = 0x10030000  ; UNSIGNEDMETER
Control18 = 0x20010000  ; BOOLEAN
Control19 = 0x21010000  ; BUTTON
Control20 = 0x30040000  ; DECIBELS
Control21 = 0x30020000  ; SIGNED
Control22 = 0x30030000  ; UNSIGNED
Control23 = 0x30050000  ; PERCENT
Control24 = 0x40020000  ; SLIDER
Control25 = 0x50030000  ; FADER
Control26 = 0x70010000  ; SINGLESELECT
Control27 = 0x70010001  ; MUX
Control28 = 0x71010000  ; MULTIPLESELECT
Control29 = 0x71010001  ; MIXER
Control30 = 0x60030000  ; MICROTIME
Control31 = 0x61030000  ; MILLITIME

; Create a ListView and prepare for the main loop:
Gui, Add, Listview, w400 h400 vMyListView, Component Type|Control Type|Setting|Mixer
LV_ModifyCol(4, "Integer")
SetFormat, Float, 0.2  ; Limit number of decimal places in percentages to two.

Loop  ; For each mixer number that exists in the system, query its capabilities.
{
	CurrMixer := A_Index
	SoundGet, Setting,,, %CurrMixer%
	if ErrorLevel = Can't Open Specified Mixer  ; Any error other than this indicates that the mixer exists.
		break

	Loop  ; For each component type that exists in this mixer, query its instances and control types.
	{
		CurrComponent := Component%A_Index%
		if CurrComponent =
			break  ; No more component types in array.
		; First check if this component type even exists in the mixer:
		SoundGet, Setting, %CurrComponent%,, %CurrMixer%
		if ErrorLevel = Mixer Doesn't Support This Component Type
			continue  ; Start a new iteration to move on to the next component type.
		Loop  ; For each instance of this component type, query its control types.
		{
			CurrInstance := A_Index
			; First check if this instance of this instance even exists in the mixer:
			SoundGet, Setting, %CurrComponent%:%CurrInstance%,, %CurrMixer%
			; Checking for both of the following errors allows this script to run on older versions:
			if ErrorLevel in Mixer Doesn't Have That Many of That Component Type,Invalid Control Type or Component Type
				break  ; No more instances of this component type.
			Loop  ; Get the current setting of each control type that exists in this instance of this component.
			{
				CurrControl := Control%A_Index%
				if CurrControl =
					break  ; No more control types in array.
				SoundGet, Setting, %CurrComponent%:%CurrInstance%, %CurrControl%, %CurrMixer%
				; Checking for both of the following errors allows this script to run on older versions:
				if ErrorLevel in Component Doesn't Support This Control Type,Invalid Control Type or Component Type
					continue
				if ErrorLevel  ; Some other error, which is unexpected so show it in the results.
					Setting := ErrorLevel
				ComponentString := CurrComponent
				if CurrInstance > 1
					ComponentString = %ComponentString%:%CurrInstance%
				LV_Add("", ComponentString, CurrControl, Setting, CurrMixer)
			}  ; For each control type.
		}  ; For each component instance.
	}  ; For each component type.
}  ; For each mixer.

Loop % LV_GetCount("Col")  ; Auto-size each column to fit its contents.
	LV_ModifyCol(A_Index, "AutoHdr")

SplashTextOff
Gui, Show
return

GuiClose:
ExitApp