After decimating the enemy forces that have attacked your ship, you are charged with taking out as many of the remaining enemy fighters as possible. 3d space fighter game was initially written while I was testing some 3d routines I was implementing for a flight simulator, but my daughter started playing it and seemed to enjoy it so I added a few sound effects, explosions etc. and so this little game was born.

Dependencies:   mbed

OneBitSound/SoundChannel.h

Committer:
taylorza
Date:
2015-02-08
Revision:
4:b857db213f10
Parent:
1:9ff7384171ec

File content as of revision 4:b857db213f10:

#ifndef __SOUNDCHANNEL_H__
#define __SOUNDCHANNEL_H__
class SoundChannel
{   
public: 
    SoundChannel();
    
    protected:
        void play(const SoundBlock soundBlocks[], int count);
        bool update(bool &pinState);            
    
    private:
        void updateTone();
        void updateNoise();
        
        void startSoundBlock();
        bool updateCounters();
        void updateAudioCounters();
        
        static uint16_t lfsr_rand();
        
    private:
        int         _state;
        uint16_t    _stepCounter;
        uint16_t    _stepDurationCounter;
        fix16_t     _basePitchHighCount;
        fix16_t     _basePitchLowCount;
        fix16_t     _pitchHighCounter;
        fix16_t     _pitchLowCounter;
        fix16_t     _pitchOffset;
        fix16_t     _dutyOffset;
        
        const SoundBlock *_soundBlocks;        
        int         _count;
        int         _index;  
        bool        _pinState;
        
        SoundBlock  _currentSoundBlock;
        
    friend class OneBitSound;           
};
#endif //__SOUNDCHANNEL_H__