2 #define WIN32_LEAN_AND_MEAN
8 inline void Sleep(uint32_t ms
)
10 struct timespec ts
, rem
;
11 ts
.tv_sec
= ms
/ 1000;
12 ts
.tv_nsec
= (ms
% 1000) * 1000000;
13 while(nanosleep(&ts
, &rem
) == -1 && errno
== EINTR
)
24 #include "efx-presets.h"
26 template<typename T
, size_t N
>
27 static inline size_t countof(const T(&)[N
])
30 #define DECL(x) { #x, EFX_REVERB_PRESET_##x }
33 EFXEAXREVERBPROPERTIES props
;
46 DECL(CARPETEDHALLWAY
),
62 DECL(CASTLE_SMALLROOM
),
63 DECL(CASTLE_SHORTPASSAGE
),
64 DECL(CASTLE_MEDIUMROOM
),
65 DECL(CASTLE_LARGEROOM
),
66 DECL(CASTLE_LONGPASSAGE
),
68 DECL(CASTLE_CUPBOARD
),
69 DECL(CASTLE_COURTYARD
),
72 DECL(FACTORY_SMALLROOM
),
73 DECL(FACTORY_SHORTPASSAGE
),
74 DECL(FACTORY_MEDIUMROOM
),
75 DECL(FACTORY_LARGEROOM
),
76 DECL(FACTORY_LONGPASSAGE
),
78 DECL(FACTORY_CUPBOARD
),
79 DECL(FACTORY_COURTYARD
),
82 DECL(ICEPALACE_SMALLROOM
),
83 DECL(ICEPALACE_SHORTPASSAGE
),
84 DECL(ICEPALACE_MEDIUMROOM
),
85 DECL(ICEPALACE_LARGEROOM
),
86 DECL(ICEPALACE_LONGPASSAGE
),
88 DECL(ICEPALACE_CUPBOARD
),
89 DECL(ICEPALACE_COURTYARD
),
90 DECL(ICEPALACE_ALCOVE
),
92 DECL(SPACESTATION_SMALLROOM
),
93 DECL(SPACESTATION_SHORTPASSAGE
),
94 DECL(SPACESTATION_MEDIUMROOM
),
95 DECL(SPACESTATION_LARGEROOM
),
96 DECL(SPACESTATION_LONGPASSAGE
),
97 DECL(SPACESTATION_HALL
),
98 DECL(SPACESTATION_CUPBOARD
),
99 DECL(SPACESTATION_ALCOVE
),
101 DECL(WOODEN_SMALLROOM
),
102 DECL(WOODEN_SHORTPASSAGE
),
103 DECL(WOODEN_MEDIUMROOM
),
104 DECL(WOODEN_LARGEROOM
),
105 DECL(WOODEN_LONGPASSAGE
),
107 DECL(WOODEN_CUPBOARD
),
108 DECL(WOODEN_COURTYARD
),
111 DECL(SPORT_EMPTYSTADIUM
),
112 DECL(SPORT_SQUASHCOURT
),
113 DECL(SPORT_SMALLSWIMMINGPOOL
),
114 DECL(SPORT_LARGESWIMMINGPOOL
),
115 DECL(SPORT_GYMNASIUM
),
116 DECL(SPORT_FULLSTADIUM
),
117 DECL(SPORT_STADIUMTANNOY
),
119 DECL(PREFAB_WORKSHOP
),
120 DECL(PREFAB_SCHOOLROOM
),
121 DECL(PREFAB_PRACTISEROOM
),
122 DECL(PREFAB_OUTHOUSE
),
123 DECL(PREFAB_CARAVAN
),
127 DECL(DOME_SAINTPAULS
),
132 DECL(OUTDOORS_BACKYARD
),
133 DECL(OUTDOORS_ROLLINGPLAINS
),
134 DECL(OUTDOORS_DEEPCANYON
),
135 DECL(OUTDOORS_CREEK
),
136 DECL(OUTDOORS_VALLEY
),
142 DECL(DRIVING_COMMENTATOR
),
143 DECL(DRIVING_PITGARAGE
),
144 DECL(DRIVING_INCAR_RACER
),
145 DECL(DRIVING_INCAR_SPORTS
),
146 DECL(DRIVING_INCAR_LUXURY
),
147 DECL(DRIVING_FULLGRANDSTAND
),
148 DECL(DRIVING_EMPTYGRANDSTAND
),
149 DECL(DRIVING_TUNNEL
),
155 DECL(CITY_UNDERPASS
),
156 DECL(CITY_ABANDONED
),
160 DECL(SMALLWATERROOM
),
165 int main(int argc
, char *argv
[])
167 alure::DeviceManager
*devMgr
= alure::DeviceManager::get();
169 alure::Device
*dev
= devMgr
->openPlayback();
170 std::cout
<< "Opened \""<<dev
->getName(alure::PlaybackDevType_Basic
)<<"\"" <<std::endl
;
172 alure::Context
*ctx
= dev
->createContext();
173 alure::Context::MakeCurrent(ctx
);
175 bool gotreverb
= false;
176 alure::Effect
*effect
= ctx
->createEffect();
179 if(argc
-i
>= 2 && strcasecmp(argv
[i
], "-preset") == 0)
181 for(size_t j
= 0;j
< countof(reverblist
);j
++)
183 if(strcasecmp(argv
[i
+1], reverblist
[j
].name
) == 0)
185 std::cout
<< "Loading preset "<<reverblist
[j
].name
<<std::endl
;
188 effect
->setReverbProperties(reverblist
[j
].props
);
197 std::cout
<< "Loading generic preset" <<std::endl
;
200 effect
->setReverbProperties(EFX_REVERB_PRESET_GENERIC
);
203 alure::AuxiliaryEffectSlot
*auxslot
= ctx
->createAuxiliaryEffectSlot();
204 auxslot
->applyEffect(effect
);
208 alure::SharedPtr
<alure::Decoder
> decoder(ctx
->createDecoder(argv
[i
]));
209 alure::Source
*source
= ctx
->getSource();
211 source
->setAuxiliarySend(auxslot
, 0);
213 source
->play(decoder
, 32768, 4);
214 std::cout
<< "Playing "<<argv
[i
]<<" ("<<alure::GetSampleTypeName(decoder
->getSampleType())<<", "
215 <<alure::GetChannelConfigName(decoder
->getChannelConfig())<<", "
216 <<decoder
->getFrequency()<<"hz)" <<std::endl
;
218 float invfreq
= 1.0f
/ decoder
->getFrequency();
219 while(source
->isPlaying())
221 std::cout
<< "\r "<<std::setiosflags(std::ios::fixed
)<<std::setprecision(2)<<
222 (source
->getOffset()*invfreq
)<<" / "<<(decoder
->getLength()*invfreq
);
227 std::cout
<<std::endl
;
239 alure::Context::MakeCurrent(0);