1
0
Fork 0

Reshuffled some of the sound code and created a "src/Sound" subdirectory.

This commit is contained in:
curt 2001-03-05 22:54:20 +00:00
parent fbad3482fa
commit 815d49e86a
10 changed files with 66 additions and 159 deletions

View file

@ -2373,6 +2373,21 @@ SOURCE=.\src\Main\options.cxx
# End Source File
# Begin Source File
SOURCE=.\src\Main\soundmgr.cxx
!IF "$(CFG)" == "FlightGear - Win32 Release"
# PROP Intermediate_Dir "Release\main"
!ELSEIF "$(CFG)" == "FlightGear - Win32 Debug"
# PROP Intermediate_Dir "Debug\main"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\src\Main\splash.cxx
!IF "$(CFG)" == "FlightGear - Win32 Release"

View file

@ -42,9 +42,7 @@ fgfs_SOURCES = \
fgfs.cxx fgfs.hxx \
globals.cxx globals.hxx \
keyboard.cxx keyboard.hxx \
morse.cxx morse.hxx \
options.cxx options.hxx \
soundmgr.cxx soundmgr.hxx \
splash.cxx splash.hxx \
viewer.cxx viewer.hxx \
viewer_lookat.cxx viewer_lookat.hxx \
@ -65,6 +63,7 @@ fgfs_LDADD = \
$(top_builddir)/src/GUI/libGUI.a \
$(top_builddir)/src/Navaids/libNavaids.a \
$(top_builddir)/src/Scenery/libScenery.a \
$(top_builddir)/src/Sound/libSound.a \
$(top_builddir)/src/Airports/libAirports.a \
$(NETWORK_LIBS) \
$(top_builddir)/src/Objects/libObjects.a \

View file

@ -36,7 +36,7 @@
#include <simgear/timing/sg_time.hxx>
#include <simgear/misc/props.hxx>
#include "soundmgr.hxx"
#include <Sound/soundmgr.hxx>
#include "viewmgr.hxx"
FG_USING_STD( vector );

View file

@ -83,6 +83,10 @@
#endif
#include <Scenery/scenery.hxx>
#include <Scenery/tilemgr.hxx>
#ifdef ENABLE_AUDIO_SUPPORT
# include <Sound/soundmgr.hxx>
# include <Sound/morse.hxx>
#endif
#include <Time/event.hxx>
#include <Time/fg_timer.hxx>
#include <Time/light.hxx>
@ -117,13 +121,8 @@ int objc=0;
#include "fg_io.hxx"
#include "globals.hxx"
#include "keyboard.hxx"
#include "morse.hxx"
#include "splash.hxx"
#ifdef ENABLE_AUDIO_SUPPORT
# include "soundmgr.hxx"
#endif
#ifdef macintosh
# include <console.h> // -dw- for command line dialog
#endif
@ -1194,10 +1193,10 @@ static void fgIdleFunction ( void ) {
// s2 = new FGSimpleSound( "Sounds/corflaps.wav" );
// s2->set_volume( 2.0 );
FGMorse mmm;
mmm.init();
s2 = mmm.make_ident( "JLI" );
globals->get_soundmgr()->add( s2, "flaps" );
// FGMorse mmm;
// mmm.init();
// s2 = mmm.make_ident( "JLI" );
// globals->get_soundmgr()->add( s2, "flaps" );
}
#endif

View file

@ -1,117 +0,0 @@
// soundmgr.hxx -- Sound effect management class
//
// Sound manager initially written by David Findlay
// <david_j_findlay@yahoo.com.au> 2001
//
// C++-ified by Curtis Olson, started March 2001.
//
// Copyright (C) 2001 Curtis L. Olson - curt@flightgear.org
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// $Id$
#ifndef _SOUNDMGR_HXX
#define _SOUNDMGR_HXX
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <simgear/compiler.h>
#include STL_STRING
#include <map>
#include <plib/sl.h>
#include <plib/sm.h>
FG_USING_STD(map);
FG_USING_STD(string);
// manages everything we need to know for an individual sound sample
class FGSimpleSound {
slSample *sample;
slEnvelope *pitch_envelope;
slEnvelope *volume_envelope;
double pitch;
double volume;
public:
FGSimpleSound( string file );
FGSimpleSound( unsigned char *buffer, int len );
~FGSimpleSound();
inline double get_pitch() const { return pitch; }
inline void set_pitch( double p ) {
pitch = p;
pitch_envelope->setStep( 0, 0.01, pitch );
}
inline double get_volume() const { return volume; }
inline void set_volume( double v ) {
volume = v;
volume_envelope->setStep( 0, 0.01, volume );
}
inline slSample *get_sample() { return sample; }
inline slEnvelope *get_pitch_envelope() { return pitch_envelope; }
inline slEnvelope *get_volume_envelope() { return volume_envelope; }
};
typedef map < string, FGSimpleSound * > sound_map;
typedef sound_map::iterator sound_map_iterator;
typedef sound_map::const_iterator const_sound_map_iterator;
class FGSoundMgr {
slScheduler *audio_sched;
smMixer *audio_mixer;
sound_map sounds;
public:
FGSoundMgr();
~FGSoundMgr();
// initialize the sound manager
bool init();
// run the audio scheduler
bool update();
// is audio working?
inline bool is_working() const { return !audio_sched->not_working(); }
// add a sound effect, return the index of the sound
bool add( FGSimpleSound *sound, const string& refname );
// tell the scheduler to play the indexed sample in a continuous
// loop
bool play_looped( const string& refname );
// tell the scheduler to play the indexed sample once
bool play_once( const string& refname );
};
#endif // _SOUNDMGR_HXX

View file

@ -24,6 +24,7 @@ SUBDIRS = \
$(NETWORK_DIRS) \
Objects \
Scenery \
Sound \
Time \
$(WEATHER_DIR) \
Main

7
src/Sound/Makefile.am Normal file
View file

@ -0,0 +1,7 @@
noinst_LIBRARIES = libSound.a
libSound_a_SOURCES = \
morse.cxx morse.hxx \
soundmgr.cxx soundmgr.hxx
INCLUDES += -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -24,6 +24,36 @@
#include "morse.hxx"
static const char alphabet[26][4] = {
{ DI, DAH, end, end }, /* A */
{ DA, DI, DI, DIT }, /* B */
{ DA, DI, DA, DIT }, /* C */
{ DA, DI, DIT, end }, /* D */
{ DIT, end, end, end }, /* E */
{ DI, DI, DA, DIT }, /* F */
{ DA, DA, DIT, end }, /* G */
{ DI, DI, DI, DIT }, /* H */
{ DI, DIT, end, end }, /* I */
{ DI, DA, DA, DAH }, /* J */
{ DA, DI, DAH, end }, /* K */
{ DI, DA, DI, DIT }, /* L */
{ DA, DAH, end, end }, /* M */
{ DA, DIT, end, end }, /* N */
{ DA, DA, DAH, end }, /* O */
{ DI, DA, DA, DIT }, /* P */
{ DA, DA, DI, DAH }, /* Q */
{ DI, DA, DIT, end }, /* R */
{ DI, DI, DIT, end }, /* S */
{ DAH, end, end, end }, /* T */
{ DI, DI, DAH, end }, /* U */
{ DI, DI, DI, DAH }, /* V */
{ DI, DA, DAH, end }, /* W */
{ DA, DI, DI, DAH }, /* X */
{ DA, DI, DA, DAH }, /* Y */
{ DA, DA, DI, DIT } /* Z */
};
// constructor
FGMorse::FGMorse() {
}

View file

@ -91,6 +91,7 @@ static const char end = '0';
static const int BYTES_PER_SECOND = 8000;
static const int BEAT_LENGTH = 240; // milleseconds (5 wpm)
// static const int BEAT_LENGTH = 92; // milleseconds (13 wpm)
static const int TRANSITION_BYTES = (int)(0.005 * BYTES_PER_SECOND);
static const int COUNT_SIZE = BYTES_PER_SECOND * BEAT_LENGTH / 1000;
static const int DIT_SIZE = 2 * COUNT_SIZE; // 2 counts
@ -98,35 +99,6 @@ static const int DAH_SIZE = 4 * COUNT_SIZE; // 4 counts
static const int SPACE_SIZE = 3 * COUNT_SIZE; // 3 counts
static const int FREQUENCY = 1020; // AIM 1-1-7 (f) specified in Hz
static char alphabet[26][4] = {
{ DI, DAH, end, end }, /* A */
{ DA, DI, DI, DIT }, /* B */
{ DA, DI, DA, DIT }, /* C */
{ DA, DI, DIT, end }, /* D */
{ DIT, end, end, end }, /* E */
{ DI, DI, DA, DIT }, /* F */
{ DA, DA, DIT, end }, /* G */
{ DI, DI, DI, DIT }, /* H */
{ DI, DIT, end, end }, /* I */
{ DI, DA, DA, DAH }, /* J */
{ DA, DI, DAH, end }, /* K */
{ DI, DA, DI, DIT }, /* L */
{ DA, DAH, end, end }, /* M */
{ DA, DIT, end, end }, /* N */
{ DA, DA, DAH, end }, /* O */
{ DI, DA, DA, DIT }, /* P */
{ DA, DA, DI, DAH }, /* Q */
{ DI, DA, DIT, end }, /* R */
{ DI, DI, DIT, end }, /* S */
{ DAH, end, end, end }, /* T */
{ DI, DI, DAH, end }, /* U */
{ DI, DI, DI, DAH }, /* V */
{ DI, DA, DAH, end }, /* W */
{ DA, DI, DI, DAH }, /* X */
{ DA, DI, DA, DAH }, /* Y */
{ DA, DA, DI, DIT } /* Z */
};
// manages everything we need to know for an individual sound sample
class FGMorse {

View file

@ -27,7 +27,8 @@
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/fgpath.hxx>
#include "globals.hxx"
#include <Main/globals.hxx>
#include "soundmgr.hxx"