OSDN Git Service

#32713 初コミット。SVNrev567時点での、ファイルはbranch/140707(ReBuild XGVersion)から移行したもの。
[dtxmaniaxg-verk/dtxmaniaxg-verk-git.git] / SlimDXc_Jun2010(VC++2008) / source / xact3 / Cue.cpp
1 /*
2 * Copyright (c) 2007-2010 SlimDX Group
3
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22 #include "stdafx.h"
23
24 #include "XACT3Exception.h"
25
26 #include "Cue.h"
27
28 using namespace System;
29
30 namespace SlimDX
31 {
32 namespace XACT3
33 {
34         Cue::Cue( IXACT3Cue *cue )
35         {
36                 InternalPointer = cue;
37         }
38
39         Result Cue::Destroy()
40         {
41                 HRESULT hr = InternalPointer->Destroy();
42                 return RECORD_XACT3(hr);
43         }
44
45         float Cue::GetVariable(int index)
46         {
47                 XACTVARIABLEVALUE value;
48
49                 HRESULT hr = InternalPointer->GetVariable(static_cast<XACTVARIABLEINDEX>(index), &value);
50                 RECORD_XACT3(hr);
51
52                 return value;
53         }
54
55         int Cue::GetVariableIndex(String^ friendlyName)
56         {
57                 array<unsigned char>^ friendlyNameBytes = System::Text::ASCIIEncoding::ASCII->GetBytes(friendlyName);
58                 pin_ptr<unsigned char> pinnedFriendlyName = &friendlyNameBytes[0];
59
60                 XACTVARIABLEINDEX result = InternalPointer->GetVariableIndex(reinterpret_cast<PCSTR>(pinnedFriendlyName));
61                 return result == XACTVARIABLEINDEX_INVALID ? -1 : result;
62         }
63
64         Result Cue::Pause(bool pause)
65         {
66                 HRESULT hr = InternalPointer->Pause(pause);
67                 return RECORD_XACT3(hr);
68         }
69
70         Result Cue::Play()
71         {
72                 HRESULT hr = InternalPointer->Play();
73                 return RECORD_XACT3(hr);
74         }
75
76         Result Cue::SetMatrixCoefficients(int srcChannelCount, int dstChannelCount, array<float>^ matrixCoefficients)
77         {
78                 pin_ptr<float> pinnedMatrix = &matrixCoefficients[0];
79
80                 HRESULT hr = InternalPointer->SetMatrixCoefficients(srcChannelCount, dstChannelCount, pinnedMatrix);
81                 return RECORD_XACT3(hr);
82         }
83
84         Result Cue::SetVariable(int index, float value)
85         {
86                 HRESULT hr = InternalPointer->SetVariable(static_cast<XACTVARIABLEINDEX>(index), value);
87                 return RECORD_XACT3(hr);
88         }
89
90         Result Cue::Stop(StopFlags flags)
91         {
92                 HRESULT hr = InternalPointer->Stop(static_cast<DWORD>(flags));
93                 return RECORD_XACT3(hr);
94         }
95
96         CueInstanceProperties Cue::Properties::get()
97         {
98                 LPXACT_CUE_INSTANCE_PROPERTIES resultPointer = NULL;
99
100                 HRESULT hr = InternalPointer->GetProperties(&resultPointer);
101                 RECORD_XACT3(hr);
102
103                 CueInstanceProperties result = CueInstanceProperties(*resultPointer);
104                 CoTaskMemFree(resultPointer);
105
106                 return result;
107         }
108
109         CueState Cue::State::get()
110         {
111                 DWORD result;
112
113                 HRESULT hr = InternalPointer->GetState(&result);
114                 RECORD_XACT3(hr);
115
116                 return static_cast<CueState>(result);
117         }
118 }
119 }