Skip to content

Commit 8a18de5

Browse files
committed
svn_sync
1 parent 49eb535 commit 8a18de5

File tree

5 files changed

+57
-2
lines changed

5 files changed

+57
-2
lines changed

Client/trunk/ParaEngineClient/ParaScriptBindings/ParaScriptingAudio.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ void ParaAudio::EnableAudioEngine(bool bEnable )
2727
void ParaAudio::SetVolume(float fVolume)
2828
{
2929
CAudioEngine2::GetInstance()->SetGlobalVolume(fVolume);
30+
CMidiMsg::GetSingleton().SetVolumeFloat(fVolume);
3031
}
3132

3233
float ParaAudio::GetVolume()

Client/trunk/ParaEngineClient/doc/changes.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/** @page ParaEngine_change ParaEngine Change History
22
@author LiXizhi
33
Copyright 2004-2012 ParaEngine Corporation.
4+
2016.9.18
5+
- audio midi api volume can now be changed with global audio settings
6+
47
2016.9.14
58
- BlockModel now supports fbx file, fixed coplanar index.
69

Client/trunk/ParaEngineClient/util/MidiMsg.cpp

+36-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ CMidiMsg::CMidiMsg() :
1616
#ifdef PARAENGINE_CLIENT
1717
m_deviceMidiOut(NULL),
1818
#endif
19-
m_bIsValid(false), m_bIsLoaded(false)
19+
m_bIsValid(false), m_bIsLoaded(false), m_dwVolume(0xffffffff)
2020
{
2121
}
2222

@@ -38,6 +38,7 @@ bool ParaEngine::CMidiMsg::CheckLoad()
3838
else
3939
{
4040
m_bIsValid = true;
41+
midiOutSetVolume(m_deviceMidiOut, m_dwVolume);
4142
OUTPUT_LOG("successfully opened default MIDI device\n");
4243
}
4344
#endif
@@ -46,6 +47,40 @@ bool ParaEngine::CMidiMsg::CheckLoad()
4647

4748
}
4849

50+
DWORD ParaEngine::CMidiMsg::GetVolume() const
51+
{
52+
return m_dwVolume;
53+
}
54+
55+
void ParaEngine::CMidiMsg::SetVolume(DWORD val)
56+
{
57+
if (m_dwVolume != val)
58+
{
59+
m_dwVolume = val;
60+
61+
#ifdef PARAENGINE_CLIENT
62+
if (IsLoaded())
63+
{
64+
midiOutSetVolume(m_deviceMidiOut, m_dwVolume);
65+
}
66+
#endif
67+
}
68+
}
69+
70+
void ParaEngine::CMidiMsg::SetVolumeFloat(float val)
71+
{
72+
if (val > 1.0f)
73+
val = 1.0f;
74+
DWORD volume = (DWORD)(val * 0xffff);
75+
volume = (volume << 16) + volume;
76+
SetVolume(volume);
77+
}
78+
79+
bool ParaEngine::CMidiMsg::IsLoaded() const
80+
{
81+
return m_bIsLoaded;
82+
}
83+
4984
CMidiMsg& CMidiMsg::GetSingleton()
5085
{
5186
static CMidiMsg midiPlayer;

Client/trunk/ParaEngineClient/util/MidiMsg.h

+16
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,27 @@ namespace ParaEngine
1919
bool CheckLoad();
2020
// @param filename: if empty, it will stop last one.
2121
static void PlayMidiFile(const std::string& filename, int nLoopCount = 0);
22+
23+
/**
24+
* New volume setting. The low-order word contains the left-channel volume setting,
25+
* and the high-order word contains the right-channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence.
26+
*/
27+
DWORD GetVolume() const;
28+
void SetVolume(DWORD val);
29+
/** set both left/right volume
30+
* @param val: 0-1. where 1 is biggest one, 0 is mute.
31+
*/
32+
void SetVolumeFloat(float val);
33+
34+
/** only load when first note is played. */
35+
bool IsLoaded() const;
2236
private:
2337
#ifdef PARAENGINE_CLIENT
2438
HMIDIOUT m_deviceMidiOut;
2539
#endif
2640
bool m_bIsValid;
2741
bool m_bIsLoaded;
42+
43+
DWORD m_dwVolume;
2844
};
2945
}

0 commit comments

Comments
 (0)