Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

First working example and implementation of audio playback with OpenAL-soft library #33

Closed
wants to merge 11 commits into from

Conversation

Akuhana
Copy link
Collaborator

@Akuhana Akuhana commented Apr 13, 2020

Many things have to be reviewed here since I'm not sure how well the cmake code is going to work on other machines. The most important thing is that OpenAL-soft is working and the audio playback is functioning without any problems on my machine (as long as the main audio device isn't occupied by other processes).

The AudioHandler script needs description and modularity to be added. It is nevertheless the first working example of audio playback. Many more features are going to be implemented soon.
@Akuhana Akuhana requested a review from noah1510 as a code owner April 13, 2020 17:57
@@ -28,6 +29,9 @@ int main_game_logic(
//tick the active world
gameEngine->getActiveWorld()->tick(gameEngine->getWindow());

redhand::AudioHandler audioHandler;
audioHandler.PlaySound("sounds/test.wav");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be part of the engine for better control of the lifetime.
there should be a playSound function in the engine which plays the sound using a different thread

public:
AudioHandler();
//~AudioHandler();
void PlaySound(const char*);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const char * should be std::string

void AudioHandler::CheckErrors() {
error = alGetError();
if (error != AL_NO_ERROR){
std::cout << "There was an error" << std::endl;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be std::cerr << "ERROR::LIBREDHAND::AUDIOHANDLER::AL:ERROR" << std::endl;


using namespace redhand;

ALCenum error;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error should be a private variable of the Audiohandler with a threading safe set and get function

@@ -71,6 +71,7 @@ if (UNIX)
HINTS /usr/lib/x86_64-linux-gnu/ ${CMAKE_PREFIX_PATH}/deploy/)

target_link_libraries(${OUTPUT} ${GLFW})
target_link_libraries(${OUTPUT} libopenal.so libopenal.so.1.20.1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the glfw find_library should be used

Copy link
Owner

@noah1510 noah1510 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The license of test.wav has to be added.
  • Everything mentioned in the comments should be fixed
  • All methods and the class are missing documentation (doxygen is used you can use the doxygen extention for vscode to help you getting started)
  • The default behavior for playSound should be that the sound will be played in a different thread to allow simultanious plaing of sounds, rendering and logic calculation.

@noah1510
Copy link
Owner

The windows build has to be fixed but I will do that

@Akuhana
Copy link
Collaborator Author

Akuhana commented Apr 14, 2020

I am going to put way more functionality into the audio handler class by the end of the week. Let's not rush pushing it to the master branch.

@Akuhana
Copy link
Collaborator Author

Akuhana commented Apr 14, 2020

Btw, how do you find the license of a sound? -_-

@noah1510
Copy link
Owner

Any audio file (just like every image) has some kind of license/copyright.
You need to have the right to use sonds and images so it would be best to only have images and sounds that are in the open domain (in other words they should have an creative commons license).
If that isn't the case there might be licensing issues which should be avoided

@noah1510
Copy link
Owner

This information will usually be published alongside the sound/image

@noah1510 noah1510 linked an issue Apr 15, 2020 that may be closed by this pull request
@noah1510 noah1510 added this to the going public milestone Apr 15, 2020
@noah1510 noah1510 added Audio When working with audio libraries, add this label enhancement New feature or request labels Apr 15, 2020
static inline ALenum to_al_format(short channels, short samples);
void createDefaultDevice(ALCdevice *device);

ALCdevice *device;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to avoid raw pointers use std::shared_ptr or std::unique_ptr as much as possible.
They help avoiding nullptr exceptions and memory leaks.

@noah1510
Copy link
Owner

If you need some audio files to test the code you can use this great free sound library

@Akuhana
Copy link
Collaborator Author

Akuhana commented Jun 20, 2020

Sorry for being absent. I'm going to continue the implementation once the lectures are over. i.e. in about 20 days

@noah1510 noah1510 modified the milestones: going public, v0.1.0 Jul 2, 2020
@noah1510
Copy link
Owner

could you fork the project and work on your fork, to allow a cleaner repository?

@noah1510
Copy link
Owner

closing because the main branch is now main instead of master.

@noah1510 noah1510 closed this Jul 31, 2020
@Akuhana Akuhana deleted the Audio branch August 10, 2020 22:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Audio When working with audio libraries, add this label enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

audio library implementation
2 participants