Skip to content
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

Pitch 7platforms #3010

Merged
merged 4 commits into from Jul 9, 2013
Merged

Pitch 7platforms #3010

merged 4 commits into from Jul 9, 2013

Conversation

sergey-shambir
Copy link
Contributor

  • Implemented pitch, pan and gain for 7 platforms: iOS, OSX, android (both backends), linux (both backends), tizen, blackberry, nacl. Last 4 platforms now have unified OpenAL engine.
  • No support for windows, emscrippten, marmalade, no pitch effect on android+OpenSL since bug in OpenSL at android >= 4.0 requires some redesign: http://code.google.com/p/android/issues/detail?id=24592
  • OpenAL engine on Linux now have optional mp3 support, with OPENAL_MP3=1 make option. When option enabled, cocos dynamically linked with libmpg123 (LGPL licensed).
  • Reorganized CocosDenshionTest, added sliders for pitch/pan/gain.

Should work on NaCL and Blackberry, but I didn't tested. Tested on android, linux, tizen emulator; implementations for iOS/OSX are trivial and used in our cocos2d-x tweak, but I didn't tested TestCpp separately.

About unsupported features:

  • I'm going to add pitch support for Android+OpenES soon, maybe on near weekend
  • On emscrippten pitch cannot be implemented using SDL, but emscrippten now supports OpenAL so we can use unified openal engine on this platform too. But this feature needs extensive testing, since OpenAL on emscrippten have own javascript backend and I don't know which audio codecs are supported by javascript-based alut.
  • On windows, there are some work in another pull requests that can help to impelemnt pitch/pan/gain, so we just need wait while this work will be finished.
  • On marmalade stereo effects and pitch are hurd to implement, but maybe marmalade stuff can do it.

@metalpasman
Copy link

I will include support for pitch/pan/gain in win32 refactoring

@sergey-shambir
Copy link
Contributor Author

Thanks. Also check that in win32 OpenAL backend rewindBackgroundMusic() will not stop music, this function should just return player to music start.

@metalpasman
Copy link

Yes, I fixed rewindBackgroundMusic() yet a little different than the linux approach:

This is what you have:

    void SimpleAudioEngine::rewindBackgroundMusic()
    {
        ALint state;
        alGetSourcei(s_backgroundSource, AL_SOURCE_STATE, &state);
        if (state == AL_PLAYING)
        {
            alSourceRewind(s_backgroundSource);
            alSourcePlay(s_backgroundSource);
        }
        checkALError("rewindBackgroundMusic:alSourceRewind");
    }

This is what I've implemented:

    void SimpleAudioOpenAL::resumeBackgroundMusic()
    {
        ALint state;
        alGetSourcei(s_backgroundSource, AL_SOURCE_STATE, &state);
        if (state == AL_PAUSED || state == AL_INITIAL)
            alSourcePlay(s_backgroundSource);
        checkALError("resumeBackgroundMusic:alSourcePlay");
    } 

    void SimpleAudioOpenAL::rewindBackgroundMusic()
    {
        ALint state;
        alGetSourcei(s_backgroundSource, AL_SOURCE_STATE, &state);
        alSourceRewind(s_backgroundSource);
        if (state == AL_PLAYING)
            alSourcePlay(s_backgroundSource);
        checkALError("rewindBackgroundMusic:alSourceRewind");
    }

The difference is that I can rewind also when paused, but I had to change resumeBackgroundMusic method to also resume initial state. This means even if you have not started the background music play you can resume it.

Which approach should I consider?

@sergey-shambir
Copy link
Contributor Author

Your approach is better. But maybe rewindBackgroundMusic can also check that state == AL_PAUSED, and play->pause music at this case, so no changes in resumeBackgroundMusic required.

@sergey-shambir
Copy link
Contributor Author

A bit hard to say where is problem, but I'll try to fix build tomorrow.

1. Pitch/pan/gain support on iOS, Mac, Linux+FMOD, Android+SoundPool;
2. Unified OpenAL code with pitch/pan/gain on Linux, Tizen, Blackberry,
Native Client;
3. Bug fixed: rewindBackgroundMusic() no longer stops music on unified
OpenAL engine.
4. Optional mp3 support for Linux+OpenAL (OPENAL_MP3 make option);
5. Pan/gain (not pitch) support for Android+OpenES.
6. Reorganized CocosDenshion tests in TestCpp.

Known issues:
1. No support for windows, emscrippten, marmalade.
2. No pitch effect on Android+OpenES. It requires backend redesign:
http://code.google.com/p/android/issues/detail?id=24592
rewindBackgroundMusic to work with paused music.
@ricardoquesada
Copy link
Contributor

this looks like a nice feature.
We need a better sound engine for cocos2d v3.0, and these additions looks good! (I haven't tested the patch, but from the description, they are very welcome additions)

@minggo @dumganhar
Any plans to include this feature in cocos2d-x ? Thanks.

@minggo
Copy link
Contributor

minggo commented Jul 8, 2013

Thanks @sergey-shambir.

@ricardoquesada
Yep, it is a nice feature. We will merge it after testing.

@sergey-shambir
Copy link
Contributor Author

Oops... I've made wrong update, will fix it soon.

UPD: fixed

@minggo
Copy link
Contributor

minggo commented Jul 8, 2013

@sergey-shambir
But there is not new commit.

@sergey-shambir
Copy link
Contributor Author

Yes, I've removed it with "push origin -f"

@minggo minggo mentioned this pull request Jul 9, 2013
@minggo
Copy link
Contributor

minggo commented Jul 9, 2013

Thanks @sergey-shambir, the test looks great.
I fixed conflict in #3108.

@minggo minggo merged commit 2564ce0 into cocos2d:develop Jul 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants