1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 16:49:55 +00:00
Commit graph

604 commits

Author SHA1 Message Date
Chris Robinson
c17edfd547 Don't be so throw-happy in the sound manager 2017-09-14 16:00:43 -07:00
Chris Robinson
abe80f5868 Move the soundlist when updating a Ptr instead of copying 2017-09-14 16:00:43 -07:00
Chris Robinson
605c937572 Ensure 3D sources are spatialized
Standard OpenAL does not spatialize non-mono sounds, although the game has some
stereo sounds meant to play in 3D. The desired behavior can be achieved with
the AL_SOFT_source_spatialize extension.
2017-09-14 16:00:43 -07:00
Chris Robinson
6f57233ba1 Avoid copying the same Ptr with each iteration 2017-09-14 16:00:42 -07:00
Chris Robinson
edfba68eb5 Apply reverb and a low-pass filter when underwater
This replaces the pitch-shift effect when available.
2017-09-14 16:00:42 -07:00
Chris Robinson
27eeaf90d0 Use unordered_map for the music playlist and sound buffer caches 2017-09-14 16:00:42 -07:00
Chris Robinson
033303b911 Properly update the near water sound volume 2017-09-14 16:00:42 -07:00
Chris Robinson
0b720cd90c Set the appropriate meter/unit scale for sound 2017-09-14 16:00:41 -07:00
Chris Robinson
c790fedd3f Load an effect and filter for underwater 2017-09-14 16:00:41 -07:00
Chris Robinson
3d37cb3cf6 Load EFX functions when available 2017-09-14 16:00:41 -07:00
Chris Robinson
c5a3fb7ccd Simplify checking for near water sfx change
Rather than checking every frame you're near the water, only check when the
current cell changed (the sfx will only change when moving between interior and
exterior). It also doesn't need to look through all playing sounds, as it's a
local one not attached to a Ptr.
2017-09-14 16:00:41 -07:00
Chris Robinson
617c05f557 Make Sound and Stream sibling types
To avoid being able to accidentally cast a Stream* to a Sound*, or vice-versa.
2017-09-14 16:00:40 -07:00
Chris Robinson
9e45f6d05f Make a note that stopTrack needs to be called for a stopping track 2017-09-14 16:00:40 -07:00
Chris Robinson
9e7a49f66e Include alext.h to get OpenAL extension definitions 2017-09-14 16:00:40 -07:00
Chris Robinson
1fe60dd8e2 Replace some shared_ptrs with pointers to deque entries 2017-09-14 16:00:30 -07:00
Andrei Kortunov
1aaa8a76c5 Allow to play only one copy of given sound at time (bug #3647) 2017-08-31 16:14:48 +04:00
Harry
86ae2ae395 Improved shuffle (#1412) 2017-08-25 20:08:49 +00:00
scrawl
f0dea8b8e6 Revert "Implement a Fisher-Yates shuffle on background music" 2017-08-20 20:20:27 +00:00
Harry
2a85c5f011 Implement a Fisher-Yates shuffle on background music
This fixes sometimes getting repetitive background music
2017-08-19 14:48:00 -04:00
Lennart Bernhardt
546352dbe3 avoid starting sound updates more than necessary 2017-08-08 03:31:01 +02:00
Lennart Bernhardt
7b8278ae45 remove redundant mMusicFader variable 2017-08-08 03:17:40 +02:00
Lennart Bernhardt
60a7d3d6e0 Fade out music before change occurs 2017-08-06 20:10:56 +02:00
Allofich
42402976e3 Fixes for building in MSVC 2017-06-13 19:38:12 +09:00
Bret Curtis
d785344fad purge all instances of <boost/shared_ptr.hpp>, clean up unused headers 2017-06-09 19:08:53 +02:00
Bret Curtis
07f75e1104 replace boost::shared_ptr in extern and components 2017-06-09 19:08:53 +02:00
Ewan Higgs
38a2de3c51 convert std::autor_ptr to std::unique_ptr, originally by Ewan Higgs and updated by Bret Curtis 2017-06-09 16:49:25 +02:00
MiroslavR
d24bcbac15 Do not apply underwater effects to player's voice (Fixes #3850) 2017-04-30 18:51:49 +02:00
scrawl
5a939418fc Add missing avcodec_close (Fixes #3741) 2017-02-06 15:49:13 +01:00
Jules Blok
e9d8ff532f OpenAL_Output: When a source is finished, rewind it instead of stopping it.
This works around a bug in the MacOS OpenAL implementation.
2016-12-29 01:03:13 +01:00
MiroslavR
c34d85ffc2 Implement water sounds (Closes #451) 2016-11-28 21:34:58 +01:00
scrawl
530fb61ad0 Use OpenThreads instead of boost thread
This should allow OpenMW to work better with git versions of openscenegraph. OSG dev version 3.5.5 added the setting of thread affinity for the main thread. The problem is that in the boost/standard threading libraries, the affinity of a thread is inherited by any further threads launched from that thread, leading to these threads always running on the same core as the main thread unless you tell them not to.

With OpenThreads, the default affinity of a thread is none, no matter what parent thread it was launched from.

So, when using custom threading with OSG 3.6+, we have these options:
1. explicitely tell OSG to *not* set the thread affinity
or 2. explicitely set the thread affinity of additional threads created (possible with boost, but not possible with std::thread)
or 3. use OpenThreads
or 4. accept the suboptimal performance of non-OSG threads (in OpenMW's case the sound streaming & video threads) running on the same core as the main thread

This patch opts for 3.)

Reference: http://forum.openscenegraph.org/viewtopic.php?t=16158
2016-10-10 18:23:06 +02:00
scrawl
509e5dfe4d Include cleanup 2016-06-27 22:10:30 +02:00
scrawl
4699a8098b Include fix 2016-06-27 21:51:18 +02:00
scrawl
1739351b7a Remove now unused Sound_Decoder::rewind() 2016-06-27 21:38:04 +02:00
scrawl
dc1b010cf0 Don't analyze the loudness for sounds that don't need it 2016-06-27 21:37:13 +02:00
scrawl
965aaebbdb Analyze the loudness data as the stream is decoded for playback
Instead of getting the loudness data for the whole file in advance, we now get it piece by piece as the sound is streamed.

The benefit is that we need to decode the audio just once instead of twice.

We no longer need to rewind() the stream when the first decoding is done, this should hopefully fix bug #3453 .
2016-06-27 21:32:54 +02:00
scrawl
dfc2f3469a Don't play music if no playlist is set 2016-06-07 01:36:09 +02:00
scrawl
90a99991d1 Use empty() instead of !size() 2016-02-22 19:06:12 +01:00
scrawl
604b5d24e9 Use a ConstPtr in SoundManager 2015-12-18 18:11:30 +01:00
scrawl
4553db7b43 Merge pull request #861 from scrawl/soundcrash
Fix crash when running out of sound sources
2015-12-15 18:23:03 +01:00
scrawl
6a749e77f2 Fix crash when running out of sound sources 2015-12-15 15:12:48 +01:00
Chris Robinson
cddea4a99c Start underwater sound after updating sounds
In between the startUpdate/finishUpdate calls, changes are deferred so that
they can happen all at once. This includes starting sounds, so when the
underwater sound is started it will be immediately checked to see if it's
playing. Since it's not yet playing, it'll be seen as stopped and get cleaned
up before ever playing.
2015-12-14 14:05:01 -08:00
Chris Robinson
f47f0a996f Stop the object's old say sound before playing the new one 2015-12-11 15:49:45 -08:00
Chris Robinson
7fc2df153a Rename stopSound/stopStream to finishSound/finishStream
Since they're also used to clean up output resources, not just stopping.
2015-12-11 15:13:14 -08:00
Chris Robinson
808f701013 Use the actor's Head position for Say streams 2015-12-10 17:48:45 -08:00
Chris Robinson
a00a4bce77 Avoid some unnecessary indirection 2015-12-10 16:33:27 -08:00
scrawl
1264651af7 Fix coverity defects 2015-12-08 21:12:05 +01:00
scrawl
e69750905a Fix gcc warning about function casts 2015-12-08 16:51:50 +01:00
Chris Robinson
c75303b652 Add an option to select and enable HRTF 2015-12-05 17:14:53 -08:00
scrawl
53158d29b1 stopSound crash fix 2015-12-05 01:54:16 +01:00
Marc Zinnschlag
e0c9265148 Merge remote-tracking branch 'origin/master' 2015-12-03 15:56:24 +01:00
scrawl
86881bcf39 In first person mode, attach sound listener to the camera 2015-12-03 15:16:20 +01:00
Chris Robinson
f19f1c47c8 Fix playing pending voices without a Ptr 2015-12-02 16:09:25 -08:00
Chris Robinson
2face3d0a9 Combine duplicate code 2015-12-02 16:09:25 -08:00
Chris Robinson
1407366e51 Use a premade SoundStream object for the output's streamSound functions 2015-12-02 16:09:25 -08:00
Chris Robinson
2ee3265b66 Use a premade Sound object for the output's playSound functions 2015-12-02 16:09:25 -08:00
Chris Robinson
53718a5ca0 Use a typedef for the sound instance handle 2015-12-02 16:09:25 -08:00
Chris Robinson
3a39a92b93 Keep track of audio tracks 2015-12-02 16:09:24 -08:00
Chris Robinson
2883cdba5c Initialize the Sound object before modifying the pitch variable 2015-12-02 16:09:24 -08:00
Chris Robinson
a6db96b2d8 Update sound and stream parameters 2015-12-02 16:09:24 -08:00
Chris Robinson
4bd235284b Rename a couple members to avoid confusion 2015-12-02 16:09:24 -08:00
Chris Robinson
1ce3e7f5b9 Use a separate type for streams
They're basically the same, but it's to help avoid accidents with passing non-
streaming sounds to the stream functions, or vice-versa.
2015-12-02 16:09:24 -08:00
Chris Robinson
816015d6e6 Avoid inheriting from Sound for sound types 2015-12-02 16:09:24 -08:00
Alexander "Ace" Olofsson
24340bff95 Add a space 2015-11-30 17:47:36 +01:00
Alexander "Ace" Olofsson
6823298516 Different way to solve the type deduction issue 2015-11-30 17:42:25 +01:00
Alexander "Ace" Olofsson
a69e751089 Revert "Fix windows builds"
This reverts commit b085c09f86.
2015-11-30 17:38:46 +01:00
Alexander "Ace" Olofsson
b085c09f86 Fix windows builds
Can't instantiate a container (at least with MSVC) without knowing the exact size of the object being stored, forward-declares only work with pointers.
I couldn't see a simple way to remove the forward declare, so pointers and memory management it is.
2015-11-30 13:36:15 +01:00
Chris Robinson
4ee409af84 Load loudness data asynchronously
Currently abuses the output audio streams' background processing thread to do
the work, since there's no generalized threaded processing mechanism.
2015-11-27 09:47:14 -08:00
Chris Robinson
0f05ccf72a Use a non-recursive mutex and properly end the streaming thrread 2015-11-27 08:13:23 -08:00
Chris Robinson
b5ed2e65f8 Add a method to get the sound stream delay
This helps avoid a lock during the movie player's read method, since it needs
to sync with the current playback position which would otherwise need to get
the movie decoder's current position.
2015-11-27 06:01:50 -08:00
Chris Robinson
f3c035907c Rename Sound::update to Sound::applyUpdates 2015-11-27 04:55:17 -08:00
Chris Robinson
9568aa6a84 Use a condition variable to wake up the audio stream thread
This should make starting streams a bit more responsive, and allows us to do
more in it that really shouldn't wait for its next wake up.
2015-11-27 04:30:09 -08:00
Chris Robinson
4a078725d4 Play player voices locally 2015-11-27 02:57:44 -08:00
Chris Robinson
449eca4fb4 Properly mark streams as 2D or 3D 2015-11-27 02:36:33 -08:00
Chris Robinson
21bb2e9314 Use a deque for loudness buffers with a map lookup
Similar to Sound_Buffer, this allows individual Sound_Loudness objects to
retain a constant pointer when new ones are inserted on to the end.
2015-11-27 02:01:18 -08:00
Chris Robinson
5f8a09df97 Play player sounds (except footsteps) local to the listener 2015-11-27 02:01:18 -08:00
Chris Robinson
82f3651f81 Treat the sound offset as the offset in seconds 2015-11-27 02:01:17 -08:00
Chris Robinson
8b7587f9a6 Track whether a sound is 3D 2015-11-27 02:01:17 -08:00
Chris Robinson
fc912b135f Avoid unnecessarily friending classes 2015-11-27 02:01:17 -08:00
Chris Robinson
d4238a6d91 Add config options for the sound buffer cache size
The cache size is specified with a min/max range, intended to avoid constant
unloading once the limit is reached. This way, buffers can be unloaded down to
a reasonable mimimum, allowing some more buffers to be subsequently loaded
without causing more unloading.
2015-11-26 02:13:37 -08:00
Chris Robinson
8715add72f Store sound buffers in a deque that's filled in as needed
A deque allows existing Sound_Buffer references to remain valid as long as new
ones are back-inserted. These references can be used instead of indices.
2015-11-26 01:26:33 -08:00
Chris Robinson
8f08ca9cba Revert "Avoid unsafe sizeof(x)/sizeof(x[0]) constructs for array counting"
This reverts commit 0d4fea896c.
2015-11-25 06:06:27 -08:00
Chris Robinson
04f885d8cc Rename mReferences to mUses 2015-11-25 04:24:27 -08:00
Chris Robinson
0d4fea896c Avoid unsafe sizeof(x)/sizeof(x[0]) constructs for array counting 2015-11-25 04:24:27 -08:00
Chris Robinson
a1bdb544db Avoid an unnecessary string copy 2015-11-25 04:24:27 -08:00
Chris Robinson
aac903484c Remove a really unnecessary method 2015-11-25 04:24:26 -08:00
Chris Robinson
73448c72f6 Replace Play_NoTrack with playManualSound3D, and rename the latter 2015-11-25 04:24:26 -08:00
Chris Robinson
caae305ddd Use a sorted list for unused buffers
Helps ensure the buffers being unloaded due to cache limits are not likely to
be needed anytime soon.
2015-11-25 04:24:26 -08:00
Chris Robinson
669b7a2295 Batch update changes together, when possible
Certain OpenAL implementations, including Rapture3D, Creative's hardware
drivers, and more recent versions of OpenAL Soft, can batch together changes so
that they all occur at once, avoiding potential discontinuities with one sound
being changed before another, or the listeenr being changed before sounds are.

On other implementaitons, this is a no-op and maintains existing behavior.
2015-11-25 04:24:26 -08:00
Chris Robinson
ea70b0baee Don't store the buffer in the sound struct 2015-11-25 04:24:25 -08:00
Chris Robinson
fd7d58fe7e Reset the sound handle back to null after unloading 2015-11-25 04:24:25 -08:00
Chris Robinson
4801661b34 Stop all sounds of the given id 2015-11-25 04:24:25 -08:00
Chris Robinson
8a69f676ec Remove some duplicate code 2015-11-25 04:24:25 -08:00
Chris Robinson
45628316f8 Remove an unnecessary check 2015-11-25 04:24:25 -08:00
Chris Robinson
574c1923fe Clear unused buffers after unloading them all 2015-11-25 04:24:25 -08:00
Chris Robinson
5ad772c3b3 Fix streaming sound time 2015-11-25 04:24:25 -08:00
Chris Robinson
3ce6aee98b Return a decoder from the loadVoice function 2015-11-25 04:24:25 -08:00
Chris Robinson
24f8c78fca Store sound buffer references by index instead of string 2015-11-25 04:24:24 -08:00
Chris Robinson
f7218f5a25 Use proper mutex mechanisms and don't check al errors in the stream thread 2015-11-25 04:24:24 -08:00
Chris Robinson
f9e18cd966 Prepare all Sound_Buffer objects when one is needed
This simply sets up the Sound record data to be used by the sound output. The
actual audio buffers, stored in the Sound_Handle, are still loaded on-demand.
2015-11-25 04:24:24 -08:00
Chris Robinson
6c3953766e Use separate lists for the sound name and its buffer
This should make sound lookup a bit more efficient, especially when an integer
ID can be used.
2015-11-25 04:24:24 -08:00
Chris Robinson
fbfcc4050f Stream voice clips
Voices tend to be a bit long, and not individually replayed often. So it's
better to stream them instead of loading theminto a sound buffer. The loudness
data is very small, though, so that can be kept buffered indefinitely.
2015-11-25 04:24:24 -08:00
Chris Robinson
eee6a19e31 Add a method to stream sounds in 3D 2015-11-25 04:24:24 -08:00
Chris Robinson
f1a1dc8408 Pass relevant sound parameters to the OpenAL_SoundStream constructor 2015-11-25 04:24:24 -08:00
Chris Robinson
83721092f2 Refactor the audio streaming code to be a bit saner 2015-11-25 04:24:23 -08:00
Chris Robinson
16f72886e9 Use separate lists for openal sounds and streams 2015-11-25 04:24:23 -08:00
Chris Robinson
0f33f41d8d Actually unload sounds when running over 2015-11-25 04:24:23 -08:00
Chris Robinson
22a6811425 Limit the sound buffer cache to 15MB 2015-11-25 04:24:23 -08:00
Chris Robinson
0b2747098c Keep track of unused sound buffers 2015-11-25 04:24:23 -08:00
Chris Robinson
4073495070 Add some missing sound handling 2015-11-25 04:24:23 -08:00
Chris Robinson
e362896817 Combine some duplicate code 2015-11-25 04:24:23 -08:00
Chris Robinson
febc7b510a Remove an unneeded method 2015-11-25 04:24:23 -08:00
Chris Robinson
3fdc3c4ea9 Use a separate map for say sounds
Also restores lip movement
2015-11-25 04:24:22 -08:00
Chris Robinson
9d0018e1bc Reorder active sound data to make lookup by Ptr better 2015-11-25 04:24:22 -08:00
Chris Robinson
495e138907 Load sound loudness and store it with the Sound_Buffer
Still not used for say yet, though
2015-11-25 04:24:22 -08:00
Chris Robinson
f4c22ec49e Hold a separate list for voice sound buffers
This fixes say. Ideally voices would be streamed, but the loudness/"lip" buffer
extraction should be separated from the buffer loading code.
2015-11-25 04:24:22 -08:00
Chris Robinson
4571218827 Load the sound as needed and pass it directly to the play methods
This breaks say sounds, loudness handling, and the cache limit. Fixes are
forthcoming.
2015-11-25 04:24:22 -08:00
Chris Robinson
e2beefd8b5 Store info calculated from the ESM::Sound record 2015-11-25 04:24:22 -08:00
scrawl
f08cfa19ea Fix SoundManager::isPlaying to consider multiple entries with the same Ptr/id
Now it returns true if *any* sounds matching the given Ptr and id are playing. The previous behaviour was causing problems with "zombie" sounds (sounds that have finished playing, but weren't removed from the map yet) making the isPlaying method return false even though there's another legitimately playing sound in the map.
2015-11-19 01:06:51 +01:00
Bret Curtis
3ea3d07d44 really purge libav 2015-11-12 16:39:29 +01:00
dteviot
77a1d947cc extracted MWMechanics::getPlayer() 2015-08-21 21:12:39 +12:00
scrawl
cd2e6d4436 Move the __STDC_CONSTANT_MACROS define to cmakelists 2015-06-28 05:53:03 +02:00
scrawl
4bb3cbf0fb Remove last remains of Ogre 2015-06-03 23:04:35 +02:00
scrawl
84fd682e4e Fix for unnecessary exceptions when opening sounds
This would throw often during normal play, even though the throws are caught and ignored, can be annoying when the debugger is set to 'catch throw'.
2015-06-01 00:41:44 +02:00
scrawl
76dd3e4034 Fix lip animation regression 2015-05-24 04:40:09 +02:00
scrawl
152d690a7a Minor cleanup 2015-05-23 23:10:53 +02:00
scrawl
22f01b1232 Merge branch 'master' of https://github.com/OpenMW/openmw into osg
Conflicts:
	apps/launcher/graphicspage.cpp
	apps/opencs/editor.cpp
	apps/opencs/model/doc/document.cpp
	apps/opencs/view/render/cell.cpp
	apps/opencs/view/render/mousestate.cpp
	apps/opencs/view/render/textoverlay.cpp
	apps/opencs/view/render/worldspacewidget.cpp
	apps/openmw/mwclass/creature.cpp
	apps/openmw/mwclass/npc.cpp
	apps/openmw/mwgui/inventorywindow.cpp
	apps/openmw/mwgui/loadingscreen.cpp
	apps/openmw/mwgui/mapwindow.cpp
	apps/openmw/mwgui/pickpocketitemmodel.cpp
	apps/openmw/mwgui/waitdialog.cpp
	apps/openmw/mwmechanics/combat.cpp
	apps/openmw/mwmechanics/mechanicsmanagerimp.cpp
	apps/openmw/mwrender/globalmap.cpp
	apps/openmw/mwworld/physicssystem.cpp
	apps/openmw/mwworld/refdata.cpp
	apps/openmw/mwworld/scene.cpp
	apps/openmw/mwworld/worldimp.cpp
	components/sdlutil/sdlinputwrapper.cpp
	extern/shiny/Main/Factory.cpp
	extern/shiny/Main/MaterialInstance.cpp
	extern/shiny/Main/Platform.cpp
	extern/shiny/Main/ShaderSet.cpp
2015-05-23 20:33:44 +02:00
Rohit Nirmal
396fba7fa9 Silence -Wreorder warnings, and remove -Wno-reorder. 2015-05-21 22:46:44 -05:00
scrawl
7a3bc69df7 Readded sound listener 2015-05-12 19:02:56 +02:00
scrawl
a59940a2c7 Move MyGUI platform to components 2015-05-01 01:44:21 +02:00
scrawl
8c810e3620 Move rng to components 2015-04-22 17:58:55 +02:00
scrawl
c53a56ed6e clear stream errors before attempting the read 2015-04-21 16:10:11 +02:00
scrawl
92ef9b1c57 Rename to osg-ffmpeg-videoplayer 2015-04-19 20:14:06 +02:00
scrawl
42f6d9e15b Port video player 2015-04-19 20:07:18 +02:00
scrawl
8c7c89a4aa Port SoundManager 2015-04-13 22:48:37 +02:00
scrawl
4e69e7cc0f OpenMW compiles and runs w/o render window 2015-04-01 17:02:15 +02:00
Marc Zinnschlag
86d39cede9 Merge remote-tracking branch 'dteviot/Rng' 2015-03-15 22:04:26 +01:00
dteviot
3f28634d1f consolidate random number logic
Note, I suspect Rng::rollClosedProbability() is not needed.  The only difference between it and rollProbability() is that one time in 37k (on Windows), it will give an output of 1.0.
On some versions of Linux, the value of 1.0 will occur about 1 time in 4 billion.
2015-03-15 14:07:47 +13:00
dteviot
1d7f3474fa Fixed more MSVC 2013 warnings. 2015-03-15 08:49:03 +13:00
scrawl
3879ce6ac1 Get rid of "player" string checks (Fixes #2216) 2015-03-11 23:07:39 +01:00
dteviot
e197f5318b fixing MSVC 2013 warning C4244: & C4305
conversion from 'const float' to 'int', possible loss of data
conversion from 'double' to 'int', possible loss of data
conversion from 'float' to 'int', possible loss of data
2015-03-08 13:07:29 +13:00
dteviot
407cd50890 fixed warning C4099:
type name first seen using 'class' now seen using 'struct'
2015-03-06 21:36:42 +13:00
scrawl
ad8790fba0 Fix setWaterLevel script instruction not affecting physics 2015-02-08 15:50:40 +01:00
scrawl
fec8cf91f5 Add exception handling to various uses of DataStream::read 2015-01-31 22:40:42 +01:00
scrawl
855fe33c59 Add vanilla-compatible range limiting for playloopsound (Fixes #244, Fixes #1342) 2014-12-08 23:58:20 +01:00
scrawl
cf85cbbc8e Switch sound distance model to AL_INVERSE_DISTANCE 2014-12-08 17:43:56 +01:00
scrawl
fbed429b25 Use GMSTs for sound fading distance 2014-12-08 17:25:17 +01:00
Marc Zinnschlag
29c9b6bd01 Merge remote-tracking branch 'scrawl/master' 2014-11-02 10:38:42 +01:00
scrawl
17cb181f88 Use av_get_default_channel_layout for unknown channel layouts 2014-11-01 19:37:54 +01:00
scrawl
efa4d09c48 Fix crash when avcodec_decode_audio4 doesn't return a full frame (Fixes #2088) 2014-11-01 19:32:07 +01:00