Music Fader for Cocos2dx

Here’s a class for fading music in Cocos2dx 2.x using the SimpleAudioEngine. Seems like this should be a basic function of the SimpleAudioEngine itself, but this is pretty easy to use, just run it on any CCNode like any other action:

runAction(MusicFade::create(1.0f, 0.0f, true));

Copy and paste from below, or here’s a zip with the files.

#include "MusicFade.h"
#include "SimpleAudioEngine.h"

using namespace cocos2d;
using namespace CocosDenshion;

    m_initialVal = 0;
    m_targetVal = 0;

MusicFade* MusicFade::create(float duration, float volume, bool pauseOnComplete)
    MusicFade *pAction = new MusicFade();
    pAction->initWithDuration(duration, volume, pauseOnComplete);

    return pAction;

bool MusicFade::initWithDuration(float duration, float volume, bool pauseOnComplete)
    if (CCActionInterval::initWithDuration(duration))
        m_targetVal = volume;
        m_bPauseOnComplete = pauseOnComplete;
        return true;

    return false;

void MusicFade::update(float time)
    float vol = m_initialVal + time*(m_targetVal - m_initialVal);


void MusicFade::startWithTarget(CCNode *pTarget)
    CCActionInterval::startWithTarget( pTarget );
    m_initialVal = SimpleAudioEngine::sharedEngine()->getBackgroundMusicVolume();

void MusicFade::stop(void)
    if(m_bPauseOnComplete) SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
#ifndef __MusicFade__
#define __MusicFade__

#include "cocos2d.h"

class MusicFade : public cocos2d::CCActionInterval

    static MusicFade* create(float d, float volume, bool pauseOnComplete = false );
    bool initWithDuration(float d, float volume, bool pauseOnComplete );

    virtual void startWithTarget(cocos2d::CCNode *pTarget);
    virtual void update(float time);
    virtual void stop(void);

    float m_targetVal;
    float m_initialVal;
    bool m_bPauseOnComplete;

#endif /* defined(__MusicFade__) */

GLYF Design now Fuguelike

Glyf Design has changed it’s name to Fuguelike.

Why? Glyf Design was created back in 2006. The ‘design’ label is no longer accurate. And ‘glyf’ seems to be confusing for many people to read.

Fuguelike is an unusual word, and it has a double connotation: First it is the name for the baroque form of music that has a formal structure and a mathematical beauty. There is also the fugue state – a memoryless dreamlike trance. The aim is to produce both through digital experiences.

This blog’s new domain will be, although it will be duplicated here for a while longer as well.


VOSC Update now Live

An update to VOSC Visual Particle Synthesizer is now live online. It includes a new RANDOMIZE function, which loads random values for all parameters of all oscillators. Since it’s random, a lot of times the result won’t look like anything, but every once in a while something interesting will pop up. It’s a great way to explore the realm of the program’s capability, and to find a place to start tweaking from.

The update also includes a way to cap the particle resolution so that loading patches that have high settings won’t slow your machine down to a crawl. Find it in the RES panel.

This update is live online and on the Android version. Pending approval on iOS.

Announcing VOSC Visual Particle Synthesizer

Here are a couple screens from an app currently under development, to be released on iOS and Android, with other platforms/versions to follow.

It could be described as a visual particle synthesizer. It consists mainly of 4 oscillators that control the position of a vast array of on-screen particles. Adjustments to the frequency and shapes of the oscillators can produce some very intricate moving patterns.

It’s an evolution and systemization of the phaSing series of flash toys that I made quite a while back. Here, the rendering and most of the “synthesis” calculations are performed using GPU shaders written in AGAL for the Stage3D feature of Flash Player / AIR.