-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Read Only]Sfx sounds #420
Conversation
@@ -116,6 +117,46 @@ char* LoaderSDT::loadToMemory(size_t index, bool asWave) { | |||
return nullptr; | |||
} | |||
|
|||
static int read_packet(void *opaque, uint8_t *buf, int buf_size) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make opaque
a more useful name? Also, buf_size
should be a size_t.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Api forces buf_size
to to be int.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About upaque, I don't have better idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it a 'handle'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a callback the way it's implemented is already a good choice.
There should probably be a comment stating that this is an // ffmpeg XYZ callback
(whatever XYZ is).
However, when casting the opaque you could give a more descriptive name than bd
(although it's somewhat self documenting due to the cast)
You don't use Also needs a rebase ATM. |
Please check: https://github.com/rwengine/openrw/pull/420/files#diff-e9cc6b7c0e9b40ae49ea18ed92518bfcR205 |
rwlib/source/loaders/LoaderSDT.cpp
Outdated
ioBuffer = reinterpret_cast<uint8_t*>(av_malloc(ioBufferSize)); /// Will be freeded in SoundManager after buffering | ||
|
||
bd = std::make_unique<bufferData>(); | ||
av_register_all(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
av_register_all()
is deprecated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes (in ffmpeg 4.0), it's also unneeded. To remove.
std::vector<int16_t> data; | ||
|
||
size_t channels; | ||
size_t sampleRate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why these two are type of size_t
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WaveHeader is using uint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I missed that.
Two questions: Should I prepare high level function for each opcode in SoundManager, without grabbing reference of sound? (Example of that high level function is playSound for 018c) |
rwengine/src/audio/Sound.hpp
Outdated
|
||
bool isPlaying() const; | ||
bool isPaused() const; | ||
bool isStoped() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misspelled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah
Synchronization of what, exactly? Please leave opcode stuff to a follow-up PR as this is already large. |
Yeah, pull is huge I'll try to extract/backport refactoring of code. About synchronization, I was thinking about preparing ground for future resource manager. But it looks there's no need for now. |
Function loadSound returns AVFormatContext with custom AVIOContext.
Most important changes: - SoundManager manage all avaible types of sounds, - each sound contains "direct" methods, (so we reduce duplicated searches on map by grabbing ref and calling all needed methods on it (additionally for most opcodes there high level wrapping methods)), - binaural sound(although graabing parameters of listener should be improved), - implementation all staff needed for handling sfx sounds.
Signed-off-by: Filip Gawin <filip.gawin@zoho.com>
Better, but there're some artifacts in case of wav files.
@@ -17,6 +17,8 @@ | |||
#include <data/CutsceneData.hpp> | |||
|
|||
#include <boost/algorithm/string/predicate.hpp> | |||
#include <string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To remove.
rwengine/src/audio/SoundManager.hpp
Outdated
#include "audio/Sound.hpp" | ||
|
||
/// Script is using different numeration of sounds | ||
/// than postion index in sfx file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
position
int sfx; | ||
int range; | ||
}; | ||
/// Hardcoded array for translation script index into sfx index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translating
|
||
private: | ||
std::vector<int16_t> data; | ||
/// Setting velocity of velocity for openAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of listener
rwengine/src/audio/SoundManager.hpp
Outdated
@@ -1,6 +1,7 @@ | |||
#ifndef _RWENGINE_SOUNDMANAGER_HPP_ | |||
#define _RWENGINE_SOUNDMANAGER_HPP_ | |||
|
|||
#include <algorithm> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should include only what you use in that file. So algorithm
is better included in the cpp file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC some small function in headers are using it.
Everything useful has been extracted. ;) |
A lot of changes after #372.
To do:
To do (after?)
As always feedback and criticism are welcome.
#edit1 implemented hardcoded table for translating between script and sfx numeration.
#edit2 plugged leaks.
#edit3 fixed build system.