载入中...
搜索中...
未找到
Audio.cpp
浏览该文件的文档.
32 std::unique_ptr<ALCdevice, decltype(&alcCloseDevice)> deviceOwner(alcOpenDevice(nullptr), &alcCloseDevice);
39 std::unique_ptr<ALCcontext, decltype(releaseContext)> contextOwner(alcCreateContext(device, nullptr),
42 if (!context || !alcMakeContextCurrent(context)) throw eve::Exception("Could not create OpenAL context");
83 cv.wait_for(lock, std::chrono::milliseconds(10), [this] { return !running.load() || !streamSources.empty(); });
104 streamSources.erase(std::remove(streamSources.begin(), streamSources.end(), s), streamSources.end());
127 if (type != "static" && type != "stream") throw eve::Exception("Invalid source type '%s'", type.c_str());
148 if (type != "static" && type != "stream") throw eve::Exception("Invalid source type '%s'", type.c_str());
222 auto src = table.addClass<Source>("Source", std::function<Source*()>([]() -> Source* { return nullptr; }), true);
242 src.addFunc("fadeTo", [vm = table.getHandle()](Source* self, float target, float duration, float now) {
245 src.addFunc("fadeOutAndStop", [vm = table.getHandle()](Source* self, float duration, float now) {
249 [vm = table.getHandle()](Source* self) { return eve::script::projectResult(vm, self->cancelFade()); });
275 table.addFunc("applyUnderwaterAudio", [vm = table.getHandle()](Source* down, Source* up, Source* ambience,
279 vm, applyUnderwaterAudio(down, up, ambience, playDown, playUp, loopAmbience, volume, fadeSeconds, now));
295 zoneProfile.addFunc("addItem", [vm = table.getHandle()](AudioZoneProfile* p, const AudioZoneItem* item) {
299 : Result<int>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "profile and item required"));
302 zoneProfile.addFunc("getItemCount", [](const AudioZoneProfile* p) { return p ? p->itemCount() : 0; });
307 "evaluateAudioZone", [vm = table.getHandle()](const AudioZoneProfile* p, AudioZoneState* state, float now,
std::map< std::string, std::vector< Key >, std::less<> > channels
Definition AnimCurveLibrary.cpp:21
#define EV_PROFILE_MODULE(module, name)
Profile the enclosing scope, tagged with a module for grouping.
Definition Profile.h:158
The single Squirrel projection for common Result, Status and Value.
OpenAL audio module: device management, master listener state, and Source factory....
Definition Audio.h:34
Source * newSourceFromDecoder(sound::Decoder *decoder, std::string type)
Creates a Source from a decoder; type must be "static" or "stream".
Definition Audio.cpp:126
void unregisterSource(Source *s)
Internal: removes a source from all module tracking.
Definition Audio.cpp:102
void setVolume(float v)
Sets master volume (clamped to >= 0) applied to the OpenAL listener.
Definition Audio.cpp:188
void setVelocity(float x, float y, float z)
Sets the listener velocity (used by OpenAL doppler).
Definition Audio.cpp:195
void stopAll()
Stops every live Source and permanently closes caller-fed PCM streams.
Definition Audio.cpp:170
void setPosition(float x, float y, float z)
Sets the listener position in world units.
Definition Audio.cpp:194
Source * newSourceFromData(Data *data, std::string type)
Creates a Source from raw encoded data; type must be "static" or "stream".
Definition Audio.cpp:147
Source * newSource(sound::SoundData *data)
Creates a static (non-streaming) Source from decoded sound data.
Definition Audio.cpp:112
Result< std::unique_ptr< PcmStream > > newPcmStream(int sampleRate, int channels)
Allocate a bounded PCM stream without a Sound/decoder dependency.
Definition Audio.cpp:119
void registerStream(Source *s)
Internal: registers a streaming source with the decode worker.
Definition Audio.cpp:97
void unregisterStream(Source *s)
Internal: removes a source from worker tracking.
Definition Audio.cpp:108
int getSourceCount()
Return the current number of caller- or handler-owned live sources.
Definition Audio.cpp:183
void setOrientation(float fx, float fy, float fz, float ux, float uy, float uz)
Sets the listener forward and up orientation vectors.
Definition Audio.cpp:196
void pump()
Advances streaming sources; call once per frame from the main thread.
Definition Audio.cpp:201
A playable audio source (static buffer or streaming decoder). Not thread-safe for playback control ex...
Definition Source.h:30
void setVolume(float v)
Sets source gain (clamped to >= 0). Does not cancel an active fade target.
Definition Source.cpp:218
float getVolume() const
Returns the audible user volume after the last advanceFade (or committed volume).
Definition Source.cpp:225
void setVelocity(float x, float y, float z)
Sets the source velocity (used by OpenAL doppler).
Definition Source.cpp:282
void setRelative(bool relative)
Makes the source ignore the listener position (head-relative).
Definition Source.cpp:284
void setPosition(float x, float y, float z)
Sets the source position in world units.
Definition Source.cpp:272
double getDuration() const
Total duration in seconds (0 for live/unbounded streams).
Definition Source.cpp:265
void setAttenuationDistances(float ref, float max)
Sets OpenAL reference and maximum attenuation distances.
Definition Source.cpp:288
bool seek(double seconds)
Seeks to a time in seconds; false when seeking is unsupported.
Definition Source.cpp:239
void setDirection(float x, float y, float z)
Sets the source directional cone orientation.
Definition Source.cpp:283
Streaming audio decoder (medialoader-backed). Native builds own encoded bytes and decode incrementall...
Definition Decoder.h:23
Raw PCM audio buffer with format metadata (samples/rate/bit depth/channels).
Definition SoundData.h:15
void bindAudioEventSinkOwner(Audio *owner) noexcept
Bind the live Audio module into the platform event pump sink. @ownership Borrowed; cleared when the A...
Definition EventSink.cpp:36
Result< AudioZoneOutput > evaluateAudioZone(const AudioZoneProfile &p, AudioZoneState &state, float now, float px, float py, float pz, float master, std::uint32_t seed)
Evaluate PcgAudioManager/PcgAudioZone for one explicit time and player observation.
Definition AudioZone.cpp:42
void exposePcmStream(ssq::Table &table, ssq::Class &audioClass)
Install VM-bound adapters; borrows both handles only during registration.
Definition PcmStream.cpp:200
Result< void > applyAudioZoneOutput(Source *source, const AudioZoneOutput &output)
Apply one evaluated command to the caller-selected track Source without retaining it.
Definition AudioZone.cpp:121
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
Definition SquirrelBinding.cpp:540
@ InvalidArgument