LostFoundSound.h

Go to the documentation of this file.
00001 //
00002 // Copyright 2002 Sony Corporation 
00003 //
00004 // Permission to use, copy, modify, and redistribute this software for
00005 // non-commercial use is hereby granted.
00006 //
00007 // This software is provided "as is" without warranty of any kind,
00008 // either expressed or implied, including but not limited to the
00009 // implied warranties of fitness for a particular purpose.
00010 //
00011 
00012 #ifndef LostFoundSound_h_DEFINED
00013 #define LostFoundSound_h_DEFINED
00014 
00015 #include <OPENR/OObject.h>
00016 #include <OPENR/OSubject.h>
00017 #include <OPENR/OObserver.h>
00018 #include <BallTrackingHeadData.h>
00019 #include "WAV.h"
00020 #include "def.h"
00021 
00022 enum LostFoundSoundState {
00023     LFSS_IDLE,
00024     LFSS_START,
00025     LFSS_PLAYING
00026 };
00027 
00028 static const char* const SPEAKER_LOCATOR = "PRM:/r1/c1/c2/c3/s1-Speaker:S1";
00029 static const char* const FOUND_SOUND = "FOUND_SOUND";
00030 static const char* const LOST_SOUND  = "LOST_SOUND";
00031 
00032 class LostFoundSound : public OObject {
00033 public:
00034     LostFoundSound();
00035     virtual ~LostFoundSound() {}
00036 
00037     OSubject*  subject[numOfSubject];
00038     OObserver* observer[numOfObserver];
00039 
00040     virtual OStatus DoInit   (const OSystemEvent& event);
00041     virtual OStatus DoStart  (const OSystemEvent& event);
00042     virtual OStatus DoStop   (const OSystemEvent& event);
00043     virtual OStatus DoDestroy(const OSystemEvent& event);
00044 
00045     void NotifyCommand(const ONotifyEvent& event);
00046     void ReadyPlay(const OReadyEvent& event);
00047 
00048 private:
00049     void      Play(BallTrackingHeadCommand* cmd);
00050     void      OpenSpeaker();
00051     void      NewSoundVectorData();
00052     void      LoadWAV();
00053     void      SetPowerAndVolume();
00054     WAVError  CopyWAVTo(RCRegion* region);
00055     RCRegion* FindFreeRegion();
00056     bool      IsAllRegionFree();
00057 
00058     //
00059     // 8KHz 8bits MONO (8 * 1 * 1 * 32 = 256)
00060     //
00061     static const size_t SOUND_UNIT_SIZE  = 256; // bytes / 32ms
00062     static const size_t SOUND_NUM_BUFFER = 2;
00063 
00064     LostFoundSoundState lfsoundState;
00065     OPrimitiveID   speakerID;
00066     ODesignDataID  foundSoundID;
00067     WAV            foundWAV;
00068     ODesignDataID  lostSoundID;
00069     WAV            lostWAV;
00070     WAV*           playingWAV;
00071     RCRegion*      region[SOUND_NUM_BUFFER];
00072 };
00073 
00074 #endif // LostFoundSound_h_DEFINED

Generated on Sun Dec 2 23:04:29 2007 for openSDK by  doxygen 1.3.9.1