2 * An example showing how to load and apply a reverb effect to a source.
13 #include "efx-presets.h"
15 template<typename T
, size_t N
>
16 static inline size_t countof(const T(&)[N
])
19 #define DECL(x) { #x, EFX_REVERB_PRESET_##x }
22 EFXEAXREVERBPROPERTIES props
;
35 DECL(CARPETEDHALLWAY
),
51 DECL(CASTLE_SMALLROOM
),
52 DECL(CASTLE_SHORTPASSAGE
),
53 DECL(CASTLE_MEDIUMROOM
),
54 DECL(CASTLE_LARGEROOM
),
55 DECL(CASTLE_LONGPASSAGE
),
57 DECL(CASTLE_CUPBOARD
),
58 DECL(CASTLE_COURTYARD
),
61 DECL(FACTORY_SMALLROOM
),
62 DECL(FACTORY_SHORTPASSAGE
),
63 DECL(FACTORY_MEDIUMROOM
),
64 DECL(FACTORY_LARGEROOM
),
65 DECL(FACTORY_LONGPASSAGE
),
67 DECL(FACTORY_CUPBOARD
),
68 DECL(FACTORY_COURTYARD
),
71 DECL(ICEPALACE_SMALLROOM
),
72 DECL(ICEPALACE_SHORTPASSAGE
),
73 DECL(ICEPALACE_MEDIUMROOM
),
74 DECL(ICEPALACE_LARGEROOM
),
75 DECL(ICEPALACE_LONGPASSAGE
),
77 DECL(ICEPALACE_CUPBOARD
),
78 DECL(ICEPALACE_COURTYARD
),
79 DECL(ICEPALACE_ALCOVE
),
81 DECL(SPACESTATION_SMALLROOM
),
82 DECL(SPACESTATION_SHORTPASSAGE
),
83 DECL(SPACESTATION_MEDIUMROOM
),
84 DECL(SPACESTATION_LARGEROOM
),
85 DECL(SPACESTATION_LONGPASSAGE
),
86 DECL(SPACESTATION_HALL
),
87 DECL(SPACESTATION_CUPBOARD
),
88 DECL(SPACESTATION_ALCOVE
),
90 DECL(WOODEN_SMALLROOM
),
91 DECL(WOODEN_SHORTPASSAGE
),
92 DECL(WOODEN_MEDIUMROOM
),
93 DECL(WOODEN_LARGEROOM
),
94 DECL(WOODEN_LONGPASSAGE
),
96 DECL(WOODEN_CUPBOARD
),
97 DECL(WOODEN_COURTYARD
),
100 DECL(SPORT_EMPTYSTADIUM
),
101 DECL(SPORT_SQUASHCOURT
),
102 DECL(SPORT_SMALLSWIMMINGPOOL
),
103 DECL(SPORT_LARGESWIMMINGPOOL
),
104 DECL(SPORT_GYMNASIUM
),
105 DECL(SPORT_FULLSTADIUM
),
106 DECL(SPORT_STADIUMTANNOY
),
108 DECL(PREFAB_WORKSHOP
),
109 DECL(PREFAB_SCHOOLROOM
),
110 DECL(PREFAB_PRACTISEROOM
),
111 DECL(PREFAB_OUTHOUSE
),
112 DECL(PREFAB_CARAVAN
),
116 DECL(DOME_SAINTPAULS
),
121 DECL(OUTDOORS_BACKYARD
),
122 DECL(OUTDOORS_ROLLINGPLAINS
),
123 DECL(OUTDOORS_DEEPCANYON
),
124 DECL(OUTDOORS_CREEK
),
125 DECL(OUTDOORS_VALLEY
),
131 DECL(DRIVING_COMMENTATOR
),
132 DECL(DRIVING_PITGARAGE
),
133 DECL(DRIVING_INCAR_RACER
),
134 DECL(DRIVING_INCAR_SPORTS
),
135 DECL(DRIVING_INCAR_LUXURY
),
136 DECL(DRIVING_FULLGRANDSTAND
),
137 DECL(DRIVING_EMPTYGRANDSTAND
),
138 DECL(DRIVING_TUNNEL
),
144 DECL(CITY_UNDERPASS
),
145 DECL(CITY_ABANDONED
),
149 DECL(SMALLWATERROOM
),
154 int main(int argc
, char *argv
[])
156 alure::DeviceManager
&devMgr
= alure::DeviceManager::get();
159 alure::Device dev
= [argc
,argv
,&devMgr
,&fileidx
]() -> alure::Device
161 if(argc
> 3 && strcmp(argv
[1], "-device") == 0)
165 return devMgr
.openPlayback(argv
[2]);
168 std::cerr
<< "Failed to open \""<<argv
[2]<<"\" - trying default" <<std::endl
;
171 return devMgr
.openPlayback();
173 std::cout
<< "Opened \""<<dev
.getName()<<"\"" <<std::endl
;
175 alure::Context ctx
= dev
.createContext();
176 alure::Context::MakeCurrent(ctx
);
178 bool gotreverb
= false;
179 alure::Effect effect
= ctx
.createEffect();
182 if(argc
-i
>= 2 && strcasecmp(argv
[i
], "-preset") == 0)
184 for(size_t j
= 0;j
< countof(reverblist
);j
++)
186 if(strcasecmp(argv
[i
+1], reverblist
[j
].name
) == 0)
188 std::cout
<< "Loading preset "<<reverblist
[j
].name
<<std::endl
;
191 effect
.setReverbProperties(reverblist
[j
].props
);
200 std::cout
<< "Loading generic preset" <<std::endl
;
203 effect
.setReverbProperties(EFX_REVERB_PRESET_GENERIC
);
206 alure::AuxiliaryEffectSlot auxslot
= ctx
.createAuxiliaryEffectSlot();
207 auxslot
.applyEffect(effect
);
211 alure::SharedPtr
<alure::Decoder
> decoder(ctx
.createDecoder(argv
[i
]));
212 alure::Source source
= ctx
.createSource();
214 source
.setAuxiliarySend(auxslot
, 0);
216 source
.play(decoder
, 12000, 4);
217 std::cout
<< "Playing "<<argv
[i
]<<" ("<<alure::GetSampleTypeName(decoder
->getSampleType())<<", "
218 <<alure::GetChannelConfigName(decoder
->getChannelConfig())<<", "
219 <<decoder
->getFrequency()<<"hz)" <<std::endl
;
221 float invfreq
= 1.0f
/ decoder
->getFrequency();
222 while(source
.isPlaying())
224 std::cout
<< "\r "<<std::setiosflags(std::ios::fixed
)<<std::setprecision(2)<<
225 (source
.getOffset()*invfreq
)<<" / "<<(decoder
->getLength()*invfreq
);
227 std::this_thread::sleep_for(std::chrono::milliseconds(25));
230 std::cout
<<std::endl
;
239 alure::Context::MakeCurrent(nullptr);