diff --git a/src/ArrowEffects.cpp b/src/ArrowEffects.cpp index 30f2873989..2e64038f0b 100644 --- a/src/ArrowEffects.cpp +++ b/src/ArrowEffects.cpp @@ -424,21 +424,6 @@ float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float return fPixelOffsetFromCenter; } -float ArrowEffects::GetXOffset( const PlayerState* pPlayerState, float fMidiNote ) -{ - if( fMidiNote == MIDI_NOTE_INVALID ) - return 0; - Steps *pSteps = GAMESTATE->m_pCurSteps[ pPlayerState->m_PlayerNumber ]; - const RadarValues &rv = pSteps->GetRadarValues( pPlayerState->m_PlayerNumber ); - float fMinMidiNote = rv.m_Values.v.fMinMidiNote; - float fMaxMidiNote = rv.m_Values.v.fMaxMidiNote; - if( fMinMidiNote == -1 || fMaxMidiNote == -1 ) - return 0; - float fXOffset = SCALE( fMidiNote, fMinMidiNote, fMaxMidiNote, -200.0f, 200.0f ); - fXOffset = roundf( fXOffset ); - return fXOffset; -} - float ArrowEffects::GetRotation( const PlayerState* pPlayerState, float fNoteBeat, bool bIsHoldHead ) { const float* fEffects = pPlayerState->m_PlayerOptions.GetCurrent().m_fEffects; diff --git a/src/ArrowEffects.h b/src/ArrowEffects.h index 66b6d556a6..5de2872827 100644 --- a/src/ArrowEffects.h +++ b/src/ArrowEffects.h @@ -40,9 +40,6 @@ public: // fYPos (in the case of EFFECT_DRUNK). static float GetXPos( const PlayerState* pPlayerState, int iCol, float fYOffset ); - // Shift a note's fXPos by this amount depending (on what? -aj) - static float GetXOffset( const PlayerState* pPlayerState, float fMidiNote ); - // Z position; normally 0. Only visible in perspective modes. static float GetZPos( const PlayerState* pPlayerState, int iCol, float fYPos ); diff --git a/src/GameConstantsAndTypes.cpp b/src/GameConstantsAndTypes.cpp index fb6e7ae194..bfc8dc2194 100644 --- a/src/GameConstantsAndTypes.cpp +++ b/src/GameConstantsAndTypes.cpp @@ -36,8 +36,6 @@ static const char *RadarCategoryNames[] = { "Hands", "Rolls", "Lifts", - "MinMidiNote", - "MaxMidiNote", }; XToString( RadarCategory ); XToLocalizedString( RadarCategory ); diff --git a/src/GameConstantsAndTypes.h b/src/GameConstantsAndTypes.h index aa5584f17e..8889bc0752 100644 --- a/src/GameConstantsAndTypes.h +++ b/src/GameConstantsAndTypes.h @@ -32,8 +32,6 @@ enum RadarCategory RadarCategory_Hands, RadarCategory_Rolls, RadarCategory_Lifts, - RadarCategory_MinMidiNote, - RadarCategory_MaxMidiNote, NUM_RadarCategory, // leave this at the end RadarCategory_Invalid }; @@ -84,7 +82,6 @@ enum StepsType StepsType_popn_five, StepsType_popn_nine, StepsType_guitar_five, - StepsType_karaoke_single, StepsType_lights_cabinet, NUM_StepsType, // leave this at the end StepsType_Invalid, diff --git a/src/GameInput.h b/src/GameInput.h index 1c608f8451..37f4a72af3 100644 --- a/src/GameInput.h +++ b/src/GameInput.h @@ -161,9 +161,6 @@ GameButton StringToGameButton( const InputScheme* pInputs, const RString& s ); #define GUITAR_BUTTON_STRUM_DOWN GAME_BUTTON_CUSTOM_07 #define NUM_GUITAR_BUTTONS GAME_BUTTON_CUSTOM_08 -#define KARAOKE_BUTTON_LEFT GAME_BUTTON_CUSTOM_01 -#define NUM_KARAOKE_BUTTONS GAME_BUTTON_CUSTOM_02 - #define LIGHTS_BUTTON_MARQUEE_UP_LEFT GAME_BUTTON_CUSTOM_01 #define LIGHTS_BUTTON_MARQUEE_UP_RIGHT GAME_BUTTON_CUSTOM_02 #define LIGHTS_BUTTON_MARQUEE_LR_LEFT GAME_BUTTON_CUSTOM_03 diff --git a/src/GameLoop.cpp b/src/GameLoop.cpp index 46073b4acf..2520c8ea26 100644 --- a/src/GameLoop.cpp +++ b/src/GameLoop.cpp @@ -21,16 +21,13 @@ #include "NetworkSyncManager.h" #include "RageTimer.h" #include "RageInput.h" -/* XXX -#include "PitchDetectionTest.h" -*/ static RageTimer g_GameplayTimer; static Preference g_bNeverBoostAppPriority( "NeverBoostAppPriority", false ); -/* experimental: force a specific update rate. This prevents big - * animation jumps on frame skips. 0 to disable. */ +/* experimental: force a specific update rate. This prevents big animation + * jumps on frame skips. 0 to disable. */ static Preference g_fConstantUpdateDeltaSeconds( "ConstantUpdateDeltaSeconds", 0 ); void HandleInputEvents( float fDeltaTime ); @@ -49,8 +46,9 @@ static void CheckGameLoopTimerSkips( float fDeltaTime ) static int iLastFPS = 0; int iThisFPS = DISPLAY->GetFPS(); - /* If vsync is on, and we have a solid framerate (vsync == refresh and we've sustained this - * for at least one second), we expect the amount of time for the last frame to be 1/FPS. */ + /* If vsync is on, and we have a solid framerate (vsync == refresh and we've + * sustained this for at least one second), we expect the amount of time for + * the last frame to be 1/FPS. */ if( iThisFPS != DISPLAY->GetActualVideoModeParams().rate || iThisFPS != iLastFPS ) { iLastFPS = iThisFPS; @@ -90,7 +88,7 @@ static bool ChangeAppPri() } #endif - /* If this is a debug build, don't. It makes the VC debugger sluggish. */ + // If this is a debug build, don't. It makes the VC debugger sluggish. #if defined(WIN32) && defined(DEBUG) return false; #else @@ -103,7 +101,7 @@ static void CheckFocus() if( !HOOKS->AppFocusChanged() ) return; - /* If we lose focus, we may lose input events, especially key releases. */ + // If we lose focus, we may lose input events, especially key releases. INPUTFILTER->Reset(); if( ChangeAppPri() ) @@ -115,7 +113,7 @@ static void CheckFocus() } } -/* On the next update, change themes, and load sNewScreen. */ +// On the next update, change themes, and load sNewScreen. static RString g_sNewTheme; static RString g_sNewScreen; static bool g_bForceThemeReload; @@ -134,13 +132,13 @@ namespace SAFE_DELETE( SCREENMAN ); TEXTUREMAN->DoDelayedDelete(); - /* In case the previous theme overloaded class bindings, reinitialize them. */ + // In case the previous theme overloaded class bindings, reinitialize them. LUA->RegisterTypes(); THEME->SwitchThemeAndLanguage( g_sNewTheme, THEME->GetCurLanguage(), PREFSMAN->m_bPseudoLocalize, g_bForceThemeReload ); PREFSMAN->m_sTheme.Set( g_sNewTheme ); - /* Apply the new window title, icon and aspect ratio. */ + // Apply the new window title, icon and aspect ratio. StepMania::ApplyGraphicOptions(); SCREENMAN = new ScreenManager(); @@ -167,9 +165,7 @@ void GameLoop::RunGameLoop() if( !g_sNewTheme.empty() ) DoChangeTheme(); - /* - * Update - */ + // Update float fDeltaTime = g_GameplayTimer.GetDeltaTime(); if( g_fConstantUpdateDeltaSeconds > 0 ) @@ -179,18 +175,14 @@ void GameLoop::RunGameLoop() fDeltaTime *= g_fUpdateRate; - /* XXX - PitchDetectionTest::Update(); - */ - CheckFocus(); - /* Update SOUNDMAN early (before any RageSound::GetPosition calls), to flush position data. */ + // Update SOUNDMAN early (before any RageSound::GetPosition calls), to flush position data. SOUNDMAN->Update(); /* Update song beat information -before- calling update on all the classes that - * depend on it. If you don't do this first, the classes are all acting on old - * information and will lag. (but no longer fatally, due to timestamping -glenn) */ + * depend on it. If you don't do this first, the classes are all acting on old + * information and will lag. (but no longer fatally, due to timestamping -glenn) */ SOUND->Update( fDeltaTime ); TEXTUREMAN->Update( fDeltaTime ); GAMESTATE->Update( fDeltaTime ); @@ -198,7 +190,8 @@ void GameLoop::RunGameLoop() MEMCARDMAN->Update(); NSMAN->Update( fDeltaTime ); - /* Important: Process input AFTER updating game logic, or input will be acting on song beat from last frame */ + /* Important: Process input AFTER updating game logic, or input will be + * acting on song beat from last frame */ HandleInputEvents( fDeltaTime ); if( INPUTMAN->DevicesChanged() ) @@ -212,13 +205,11 @@ void GameLoop::RunGameLoop() LIGHTSMAN->Update( fDeltaTime ); - /* - * Render - */ + // Render SCREENMAN->Draw(); } - /* If we ended mid-game, finish up. */ + // If we ended mid-game, finish up. GAMESTATE->SaveLocalData(); if( ChangeAppPri() ) @@ -302,7 +293,7 @@ void ConcurrentRenderer::RenderThread() if( m_State == RENDERING_START ) { - /* We're starting to render. Set up, and then kick the event to wake + /* We're starting to render. Set up, and then kick the event to wake * up the calling thread. */ DISPLAY->BeginConcurrentRendering(); HOOKS->SetupConcurrentRenderingThread(); @@ -315,9 +306,9 @@ void ConcurrentRenderer::RenderThread() m_Event.Unlock(); } - /* This is started during Update(). The next thing the game loop + /* This is started during Update(). The next thing the game loop * will do is Draw, so shift operations around to put Draw at the - * top. This makes sure updates are seamless. */ + * top. This makes sure updates are seamless. */ if( m_State == RENDERING_ACTIVE ) { SCREENMAN->Draw(); diff --git a/src/GameManager.cpp b/src/GameManager.cpp index d5ca19fac1..fd31199740 100644 --- a/src/GameManager.cpp +++ b/src/GameManager.cpp @@ -86,8 +86,6 @@ static const StepsTypeInfo g_StepsTypeInfos[] = { { "pnm-nine", 9, true, StepsTypeCategory_Single }, // called "pnm" for backward compat // guitar hero { "guitar-five", 5, true, StepsTypeCategory_Single }, // 5 frets, no wail - // karaoke revolution - { "karaoke", 1, false, StepsTypeCategory_Single }, // cabinet lights and other fine StepsTypes that don't exist lol { "lights-cabinet", NUM_CabinetLight, false, StepsTypeCategory_Single }, // XXX disable lights autogen for now }; @@ -2651,75 +2649,6 @@ static const Game g_Game_Guitar = TNS_W5, // m_mapW5To }; -/** Karaoke ******************************************************************/ - -static const Style g_Style_Karaoke_Single = -{ // STYLE_KARAOKE_SINGLE - true, // m_bUsedForGameplay - true, // m_bUsedForEdit - true, // m_bUsedForDemonstration - true, // m_bUsedForHowToPlay - "single", // m_szName - StepsType_karaoke_single, // m_StepsType - StyleType_OnePlayerOneSide, // m_StyleType - 1, // m_iColsPerPlayer - { // m_ColumnInfo[NUM_PLAYERS][MAX_COLS_PER_PLAYER]; - { // PLAYER_1 - { TRACK_1, 0.0f, NULL }, - }, - { // PLAYER_2 - { TRACK_1, 0.0f, NULL }, - }, - }, - { // m_iInputColumn[NUM_GameController][NUM_GameButton] - { 0, Style::END_MAPPING }, - { 0, Style::END_MAPPING }, - }, - { // m_iColumnDrawOrder[MAX_COLS_PER_PLAYER]; - 0, - }, - false, // m_bNeedsZoomOutWith2Players - false, // m_bCanUseBeginnerHelper - false, // m_bLockDifficulties -}; - -static const Style *g_apGame_Karaoke_Styles[] = -{ - &g_Style_Karaoke_Single, - NULL -}; - -static const AutoMappings g_AutoKeyMappings_Karaoke = AutoMappings ( - "", - "", - "", - AutoMappingEntry( 0, KEY_LEFT, KARAOKE_BUTTON_LEFT, false ) -); - -static const Game g_Game_Karaoke = -{ - "karaoke", // m_szName - g_apGame_Karaoke_Styles, // m_apStyles - false, // m_bCountNotesSeparately - false, // m_bAllowHopos - { // m_InputScheme - "karaoke", // m_szName - NUM_KARAOKE_BUTTONS, // m_iButtonsPerController - { // m_szButtonNames - { "Left", GAME_BUTTON_LEFT }, - }, - &g_AutoKeyMappings_Karaoke - }, - { - { GameButtonType_Step }, - }, - TNS_W1, // m_mapW1To - TNS_W2, // m_mapW2To - TNS_W3, // m_mapW3To - TNS_W4, // m_mapW4To - TNS_W5, // m_mapW5To -}; - /** Lights *******************************************************************/ static const AutoMappings g_AutoKeyMappings_Lights = AutoMappings ( @@ -2837,7 +2766,6 @@ static const Game *g_Games[] = &g_Game_Techno, &g_Game_Popn, //&g_Game_Guitar, // nope, still broken. -aj - &g_Game_Karaoke, &g_Game_Lights, }; diff --git a/src/GameState.cpp b/src/GameState.cpp index 8e20f86ec9..352a252c41 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -319,7 +319,6 @@ void GameState::Reset() m_stEditSource.Set( StepsType_Invalid ); m_iEditCourseEntryIndex.Set( -1 ); m_sEditLocalProfileID.Set( "" ); - m_iEditMidiNote = MIDI_NOTE_INVALID; m_bBackedOutOfFinalStage = false; m_bEarnedExtraStage = false; diff --git a/src/GameState.h b/src/GameState.h index b553269888..bb1285f0cb 100644 --- a/src/GameState.h +++ b/src/GameState.h @@ -312,7 +312,6 @@ public: BroadcastOnChange m_iEditCourseEntryIndex; BroadcastOnChange m_sEditLocalProfileID; Profile* GetEditLocalProfile(); - int8_t m_iEditMidiNote; // Workout stuff float GetGoalPercentComplete( PlayerNumber pn ); diff --git a/src/GhostArrowRow.cpp b/src/GhostArrowRow.cpp index 8a0c46cb48..6dee088190 100644 --- a/src/GhostArrowRow.cpp +++ b/src/GhostArrowRow.cpp @@ -9,9 +9,6 @@ #include "PlayerState.h" #include "Style.h" #include "ActorUtil.h" -/* XXX -#include "PitchDetectionTest.h" -*/ void GhostArrowRow::Load( const PlayerState* pPlayerState, float fYReverseOffset ) { @@ -47,10 +44,6 @@ void GhostArrowRow::Update( float fDeltaTime ) m_Ghost[c]->Update( fDeltaTime ); float fX = ArrowEffects::GetXPos( m_pPlayerState, c, 0 ); - /* XXX - if( PitchDetectionTest::s_ms.bVoiced ) - fX += ArrowEffects::GetXOffset( m_pPlayerState, m_pPlayerState->m_fWrappedMidiNote ); - */ float fY = ArrowEffects::GetYPos( m_pPlayerState, c, 0, m_fYReverseOffsetPixels ); float fZ = ArrowEffects::GetZPos( m_pPlayerState, c, 0 ); diff --git a/src/NoteDataUtil.cpp b/src/NoteDataUtil.cpp index c380402bf7..9d484513dc 100644 --- a/src/NoteDataUtil.cpp +++ b/src/NoteDataUtil.cpp @@ -735,22 +735,6 @@ void NoteDataUtil::CalculateRadarValues( const NoteData &in, float fSongSeconds, case RadarCategory_Hands: out[rc] = (float) in.GetNumHands(); break; case RadarCategory_Rolls: out[rc] = (float) in.GetNumRolls(); break; case RadarCategory_Lifts: out[rc] = (float) in.GetNumLifts(); break; - case RadarCategory_MinMidiNote: - break; // fill in below - case RadarCategory_MaxMidiNote: - uint8_t uMinMidiNoteOut; - uint8_t uMaxMidiNoteOut; - if( GetMinAndMaxMidiNote( in, uMinMidiNoteOut, uMaxMidiNoteOut ) ) - { - out[RadarCategory_MinMidiNote] = (float) uMinMidiNoteOut; - out[RadarCategory_MaxMidiNote] = (float) uMaxMidiNoteOut; - } - else - { - out[RadarCategory_MinMidiNote] = (float) -1; - out[RadarCategory_MaxMidiNote] = (float) -1; - } - break; default: ASSERT(0); } } @@ -828,31 +812,6 @@ float NoteDataUtil::GetChaosRadarValue( const NoteData &in, float fSongSeconds ) return min( fReturn, 1.0f ); } -bool NoteDataUtil::GetMinAndMaxMidiNote( const NoteData &in, uint8_t &uMinMidiNoteOut, uint8_t &uMaxMidiNoteOut ) -{ - int iMin = INT_MAX; - int iMax = INT_MIN; - NoteData::all_tracks_const_iterator iter = in.GetTapNoteRangeAllTracks( 0, MAX_NOTE_ROW ); - for( ; !iter.IsAtEnd(); ++iter ) - { - const TapNote &tn = *iter; - if( tn.iMidiNote != MIDI_NOTE_INVALID ) - { - iMin = min( iMin, (int)tn.iMidiNote ); - iMax = max( iMax, (int)tn.iMidiNote ); - } - } - - if( iMin != INT_MAX && iMax != INT_MIN ) - { - uMinMidiNoteOut = iMin; - uMaxMidiNoteOut = iMax; - return true; - } - - return false; -} - void NoteDataUtil::RemoveHoldNotes( NoteData &in, int iStartIndex, int iEndIndex ) { // turn all the HoldNotes into TapNotes diff --git a/src/NoteDataUtil.h b/src/NoteDataUtil.h index 47abf3cb7b..82e434ea84 100644 --- a/src/NoteDataUtil.h +++ b/src/NoteDataUtil.h @@ -36,7 +36,6 @@ namespace NoteDataUtil float GetAirRadarValue( const NoteData &in, float fSongSeconds ); float GetFreezeRadarValue( const NoteData &in, float fSongSeconds ); float GetChaosRadarValue( const NoteData &in, float fSongSeconds ); - bool GetMinAndMaxMidiNote( const NoteData &in, uint8_t &uMinMidiNoteOut, uint8_t &uMaxMidiNoteOut ); void CalculateRadarValues( const NoteData &in, float fSongSeconds, RadarValues& out ); diff --git a/src/NoteDataWithScoring.cpp b/src/NoteDataWithScoring.cpp index dc56268fc9..50cca07530 100644 --- a/src/NoteDataWithScoring.cpp +++ b/src/NoteDataWithScoring.cpp @@ -349,8 +349,6 @@ void NoteDataWithScoring::GetActualRadarValues( const NoteData &in, const Player case RadarCategory_Hands: out[rc] = (float) GetSuccessfulHands( in ); break; case RadarCategory_Rolls: out[rc] = (float) GetNumHoldNotesWithScore( in, TapNote::hold_head_roll, HNS_Held ); break; case RadarCategory_Lifts: out[rc] = (float) GetSuccessfulLifts( in, TNS_W4 ); break; - case RadarCategory_MinMidiNote: out[rc] = 0; break; // no meaning - case RadarCategory_MaxMidiNote: out[rc] = 0; break; // no meaning //case RadarCategory_Minefields: out[rc] = (float) GetNumMinefieldsWithScore( in, TapNote::hold_head_mine, HNS_Held ); break; DEFAULT_FAIL( rc ); } diff --git a/src/NoteDisplay.cpp b/src/NoteDisplay.cpp index 848d668324..d1e32e8a10 100644 --- a/src/NoteDisplay.cpp +++ b/src/NoteDisplay.cpp @@ -367,7 +367,7 @@ struct StripBuffer int Free() const { return size - Used(); } }; -void NoteDisplay::DrawHoldPart( vector &vpSpr, int iCol, int fYStep, float fXOffset, float fPercentFadeToFail, float fColorScale, bool bGlow, +void NoteDisplay::DrawHoldPart( vector &vpSpr, int iCol, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow, float fDrawDistanceAfterTargetsPixels, float fDrawDistanceBeforeTargetsPixels, float fFadeInPercentOfDrawFar, float fOverlappedTime, float fYTop, float fYBottom, @@ -443,7 +443,6 @@ void NoteDisplay::DrawHoldPart( vector &vpSpr, int iCol, int fYStep, fl const float fScaledFrameWidth = fFrameWidth * fFrameWidthScale; float fX = ArrowEffects::GetXPos( m_pPlayerState, iCol, fYOffset ); - fX += fXOffset; const float fXLeft = fX - fScaledFrameWidth/2; const float fXCenter = fX; @@ -550,14 +549,12 @@ void NoteDisplay::DrawHoldBody( const TapNote& tn, int iCol, float fBeat, bool b if( bReverse ) swap( fYStartPos, fYEndPos ); - float fXOffset = ArrowEffects::GetXOffset( m_pPlayerState, tn.iMidiNote ); - bool bTopAnchor = bReverse && cache->m_bTopHoldAnchorWhenReverse; // Draw the top cap DrawHoldPart( vpSprTop, - iCol, fYStep, fXOffset, fPercentFadeToFail, fColorScale, bGlow, + iCol, fYStep, fPercentFadeToFail, fColorScale, bGlow, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar, tn.HoldResult.fOverlappedTime, fYHead-fFrameHeightTop, fYHead, @@ -567,7 +564,7 @@ void NoteDisplay::DrawHoldBody( const TapNote& tn, int iCol, float fBeat, bool b // Draw the body DrawHoldPart( vpSprBody, - iCol, fYStep, fXOffset, fPercentFadeToFail, fColorScale, bGlow, + iCol, fYStep, fPercentFadeToFail, fColorScale, bGlow, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar, tn.HoldResult.fOverlappedTime, fYHead, fYTail, @@ -577,7 +574,7 @@ void NoteDisplay::DrawHoldBody( const TapNote& tn, int iCol, float fBeat, bool b // Draw the bottom cap DrawHoldPart( vpSprBottom, - iCol, fYStep, fXOffset, fPercentFadeToFail, fColorScale, bGlow, + iCol, fYStep, fPercentFadeToFail, fColorScale, bGlow, fDrawDistanceAfterTargetsPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar, tn.HoldResult.fOverlappedTime, fYTail, fYTail+fFrameHeightBottom, @@ -663,9 +660,7 @@ void NoteDisplay::DrawActor( const TapNote& tn, Actor* pActor, NotePart part, in if( fYOffset < fDrawDistanceAfterTargetsPixels || fYOffset > fDrawDistanceBeforeTargetsPixels ) return; const float fY = ArrowEffects::GetYPos( m_pPlayerState, iCol, fYOffset, fReverseOffsetPixels ); - float fX = ArrowEffects::GetXPos( m_pPlayerState, iCol, fYOffset ); - if( tn.iMidiNote ) - fX += ArrowEffects::GetXOffset( m_pPlayerState, tn.iMidiNote ); + const float fX = ArrowEffects::GetXPos( m_pPlayerState, iCol, fYOffset ); const float fZ = ArrowEffects::GetZPos( m_pPlayerState, iCol, fYOffset ); const float fAlpha = ArrowEffects::GetAlpha( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar ); const float fGlow = ArrowEffects::GetGlow( m_pPlayerState, iCol, fYOffset, fPercentFadeToFail, m_fYReverseOffsetPixels, fDrawDistanceBeforeTargetsPixels, fFadeInPercentOfDrawFar ); diff --git a/src/NoteDisplay.h b/src/NoteDisplay.h index 878d96333a..1e9def75b4 100644 --- a/src/NoteDisplay.h +++ b/src/NoteDisplay.h @@ -99,7 +99,7 @@ private: void DrawHoldBody( const TapNote& tn, int iCol, float fBeat, bool bIsBeingHeld, float fYHead, float fYTail, bool bIsAddition, float fPercentFadeToFail, float fColorScale, bool bGlow, float fDrawDistanceAfterTargetsPixels, float fDrawDistanceBeforeTargetsPixels, float fFadeInPercentOfDrawFar ); - void DrawHoldPart( vector &vpSpr, int iCol, int fYStep, float fXOffset, float fPercentFadeToFail, float fColorScale, bool bGlow, + void DrawHoldPart( vector &vpSpr, int iCol, int fYStep, float fPercentFadeToFail, float fColorScale, bool bGlow, float fDrawDistanceAfterTargetsPixels, float fDrawDistanceBeforeTargetsPixels, float fFadeInPercentOfDrawFar, float fOverlappedTime, float fYTop, float fYBottom, float fYStartPos, float fYEndPos, bool bWrapping, bool bAnchorToTop, bool bFlipTextureVertically ); diff --git a/src/NoteTypes.h b/src/NoteTypes.h index fe4b3ef646..479135ba6c 100644 --- a/src/NoteTypes.h +++ b/src/NoteTypes.h @@ -60,10 +60,6 @@ struct HoldNoteResult void LoadFromNode( const XNode* pNode ); }; -const int8_t MIDI_NOTE_INVALID = -1; -const int NUM_MIDI_NOTES = 128; -const int MIDI_NOTES_PER_OCTAVE = 12; - struct TapNote { enum Type @@ -96,17 +92,19 @@ struct TapNote SubType subType; // Only used if type is hold_head. Source source; TapNoteResult result; - int8_t iMidiNote; // ignored by all game types but Karaoke PlayerNumber pn; // used in routine mode bool bHopoPossible; // set just before gameplay begins - RString sAttackModifiers; // used only if Type == attack - float fAttackDurationSeconds; // used only if Type == attack + // used only if Type == attack: + RString sAttackModifiers; + float fAttackDurationSeconds; - int iKeysoundIndex; // Index into Song's vector of keysound files if nonnegative. + // Index into Song's vector of keysound files if nonnegative: + int iKeysoundIndex; - int iDuration; // used if hold_head only - HoldNoteResult HoldResult; // used if hold_head only + // also used for hold_head only: + int iDuration; + HoldNoteResult HoldResult; // XML XNode* CreateNode() const; @@ -121,7 +119,6 @@ struct TapNote type = empty; subType = SubType_Invalid; source = original; - iMidiNote = MIDI_NOTE_INVALID; pn = PLAYER_INVALID, bHopoPossible = false; fAttackDurationSeconds = 0.f; @@ -156,7 +153,6 @@ struct TapNote COMPARE(fAttackDurationSeconds); COMPARE(iKeysoundIndex); COMPARE(iDuration); - COMPARE(iMidiNote); COMPARE(pn); #undef COMPARE return true; diff --git a/src/Player.cpp b/src/Player.cpp index b005f03118..2f94be6ae4 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -41,9 +41,6 @@ #include "GameCommand.h" #include "LocalizedString.h" #include "AdjustSync.h" -/* XXX -#include "PitchDetectionTest.h" -*/ // Helper class to ensure that each row is only judged once without taking too much memory. class JudgedRows @@ -689,10 +686,6 @@ void Player::Update( float fDeltaTime ) //float fGrayYPos = SCALE( fPercentReverse, 0.f, 1.f, GRAY_ARROWS_Y_STANDARD, GRAY_ARROWS_Y_REVERSE ); float fX = ArrowEffects::GetXPos( m_pPlayerState, c, 0 ); - /* XXX - if( PitchDetectionTest::s_ms.bVoiced ) - fX += ArrowEffects::GetXOffset( m_pPlayerState, m_pPlayerState->m_fWrappedMidiNote ); - */ const float fZ = ArrowEffects::GetZPos( m_pPlayerState, c, 0 ); m_vpHoldJudgment[c]->SetX( fX ); @@ -1044,32 +1037,18 @@ void Player::UpdateHoldNotes( int iSongRow, float fDeltaTime, vectorm_pCurGame->m_szName == RString("karaoke") ) - { - int8_t iMidiNote = trtn->pTN->iMidiNote; - ASSERT( iMidiNote != MIDI_NOTE_INVALID ); - /* XXX - const float fMidiNoteMaxAllowedError = 0.25; - bIsHoldingButton &= - PitchDetectionTest::s_ms.bVoiced && - fabsf( m_pPlayerState->m_fWrappedMidiNote - iMidiNote) < fMidiNoteMaxAllowedError; - */ - } - else - { - GameInput GameI = GAMESTATE->GetCurrentStyle()->StyleInputToGameInput( iTrack, pn ); - // this previously read as bIsHoldingButton &= - // was there a specific reason for this? - Friez - bIsHoldingButton &= INPUTMAPPER->IsBeingPressed( GameI, m_pPlayerState->m_mp ); + GameInput GameI = GAMESTATE->GetCurrentStyle()->StyleInputToGameInput( iTrack, pn ); + // this previously read as bIsHoldingButton &= + // was there a specific reason for this? - Friez + bIsHoldingButton &= INPUTMAPPER->IsBeingPressed( GameI, m_pPlayerState->m_mp ); - if( m_vAlterMap.size() > 0 ) // alternate input is being used + if( m_vAlterMap.size() > 0 ) // alternate input is being used + { + for( unsigned int i=0; i < m_vAlterMap.size(); ++i ) { - for( unsigned int i=0; i < m_vAlterMap.size(); ++i ) + if( m_vAlterMap[i].inpMain == GameI ) { - if( m_vAlterMap[i].inpMain == GameI ) - { - bIsHoldingButton = bIsHoldingButton | INPUTMAPPER->IsBeingPressed( m_vAlterMap[i].inpAlt ); - } + bIsHoldingButton = bIsHoldingButton | INPUTMAPPER->IsBeingPressed( m_vAlterMap[i].inpAlt ); } } } @@ -2860,18 +2839,6 @@ void Player::CrossedRows( int iLastRowCrossed, const RageTimer &now ) } m_iFirstUncrossedRow = iLastRowCrossed+1; - - { - // find the next note and fill in m_fUpcomingMidiNote - NoteData::all_tracks_iterator iter = m_NoteData.GetTapNoteRangeAllTracks( iLastRowCrossed+1, MAX_NOTE_ROW ); - for( ; !iter.IsAtEnd(); ++iter ) - { - TapNote &tn = *iter; - if( tn.iMidiNote != MIDI_NOTE_INVALID ) - m_pPlayerState->m_fUpcomingMidiNote = tn.iMidiNote; - break; - } - } } void Player::RandomizeNotes( int iNoteRow ) diff --git a/src/PlayerState.cpp b/src/PlayerState.cpp index 16dfad8900..41ebdbc9b3 100644 --- a/src/PlayerState.cpp +++ b/src/PlayerState.cpp @@ -3,9 +3,6 @@ #include "Foreach.h" #include "GameState.h" #include "RageLog.h" -/* XXX -#include "PitchDetectionTest.h" -*/ #include "RadarValues.h" #include "Steps.h" @@ -27,8 +24,6 @@ void PlayerState::Reset() m_fLastHopoNoteMusicSeconds = -1; m_iLastHopoNoteCol = -1; - m_fUpcomingMidiNote = -1; - m_PlayerController = PC_HUMAN; m_iCpuSkill = 5; @@ -98,26 +93,6 @@ void PlayerState::Update( float fDelta ) if( m_fSecondsUntilAttacksPhasedOut > 0 ) m_fSecondsUntilAttacksPhasedOut = max( 0, m_fSecondsUntilAttacksPhasedOut - fDelta ); - - /* XXX - m_fWrappedMidiNote = -1; - if( m_fUpcomingMidiNote != -1 ) - { - m_fWrappedMidiNote = PitchDetectionTest::WrapToNearestOctave( PitchDetectionTest::s_ms.fMidiNote, m_fUpcomingMidiNote ); - } - else - { - Steps *pSteps = GAMESTATE->m_pCurSteps[m_PlayerNumber]; - if( pSteps ) - { - const RadarValues &rv = pSteps->GetRadarValues(PLAYER_1); - float fMinMidiNote = rv.m_Values.v.fMinMidiNote; - float fMaxMidiNote = rv.m_Values.v.fMaxMidiNote; - if( fMinMidiNote != -1 && fMaxMidiNote != -1 ) - m_fWrappedMidiNote = PitchDetectionTest::WrapToNearestOctave( PitchDetectionTest::s_ms.fMidiNote, (fMinMidiNote+fMaxMidiNote)/2 ); - } - } - */ } void PlayerState::ResetToDefaultPlayerOptions( ModsLevel l ) diff --git a/src/PlayerState.h b/src/PlayerState.h index df5fdcf756..ac4f5f0749 100644 --- a/src/PlayerState.h +++ b/src/PlayerState.h @@ -36,9 +36,6 @@ public: float m_fLastHopoNoteMusicSeconds; // Set to the MusicSeconds of the last note successfully strummed or hammered in a hopochain, -1, then there is no current hopo chain int m_iLastHopoNoteCol; // if -1, then there is no current hopo chain - float m_fUpcomingMidiNote; - float m_fWrappedMidiNote; - void ClearHopoState() { m_fLastHopoNoteMusicSeconds = -1; diff --git a/src/RadarValues.h b/src/RadarValues.h index 3ffa01035b..c738129fc7 100644 --- a/src/RadarValues.h +++ b/src/RadarValues.h @@ -29,8 +29,6 @@ struct RadarValues float fNumHands; float fNumRolls; float fNumLifts; - float fMinMidiNote; - float fMaxMidiNote; } v; float f[NUM_RadarCategory]; } m_Values; diff --git a/src/ReceptorArrowRow.cpp b/src/ReceptorArrowRow.cpp index edc0d07a12..d6a024fc62 100644 --- a/src/ReceptorArrowRow.cpp +++ b/src/ReceptorArrowRow.cpp @@ -6,10 +6,6 @@ #include "GameState.h" #include "PlayerState.h" #include "Style.h" -/* XXX -#include "PitchDetectionTest.h" -*/ - ReceptorArrowRow::ReceptorArrowRow() { @@ -50,24 +46,16 @@ void ReceptorArrowRow::Update( float fDeltaTime ) // m_fDark==1 or m_fFadeToFailPercent==1 should make fBaseAlpha==0 float fBaseAlpha = (1 - m_pPlayerState->m_PlayerOptions.GetCurrent().m_fDark) * (1 - m_fFadeToFailPercent); CLAMP( fBaseAlpha, 0.0f, 1.0f ); - m_ReceptorArrow[c]->SetBaseAlpha( fBaseAlpha ); + m_ReceptorArrow[c]->SetBaseAlpha( fBaseAlpha ); // set arrow XYZ float fX = ArrowEffects::GetXPos( m_pPlayerState, c, 0 ); - /* XXX - if( PitchDetectionTest::s_ms.bVoiced ) - fX += ArrowEffects::GetXOffset( m_pPlayerState, m_pPlayerState->m_fWrappedMidiNote ); - */ const float fY = ArrowEffects::GetYPos( m_pPlayerState, c, 0, m_fYReverseOffsetPixels ); const float fZ = ArrowEffects::GetZPos( m_pPlayerState, c, 0 ); m_ReceptorArrow[c]->SetX( fX ); m_ReceptorArrow[c]->SetY( fY ); m_ReceptorArrow[c]->SetZ( fZ ); - /* XXX - m_ReceptorArrow[c]->SetVisible( PitchDetectionTest::s_ms.bVoiced ); - */ - const float fRotation = ArrowEffects::ReceptorGetRotation( m_pPlayerState ); m_ReceptorArrow[c]->SetRotationZ( fRotation ); diff --git a/src/ScreenEdit.cpp b/src/ScreenEdit.cpp index 06d6cb20cc..04e42f58db 100644 --- a/src/ScreenEdit.cpp +++ b/src/ScreenEdit.cpp @@ -35,16 +35,11 @@ #include "ThemeMetric.h" #include "Game.h" #include "RageSoundReader.h" -/* XXX -#include "PitchDetectionTest.h" -*/ static Preference g_iDefaultRecordLength( "DefaultRecordLength", 4 ); static Preference g_bEditorShowBGChangesPlay( "EditorShowBGChangesPlay", true ); -// // Defines specific to ScreenEdit -// const float RECORD_HOLD_SECONDS = 0.3f; #define PLAYER_X (SCREEN_CENTER_X) @@ -284,9 +279,6 @@ void ScreenEdit::InitEditMappings() m_EditMappingsDeviceInput.button[EDIT_BUTTON_SNAP_NEXT][0] = DeviceInput(DEVICE_KEYBOARD, KEY_LEFT); m_EditMappingsDeviceInput.button[EDIT_BUTTON_SNAP_PREV][0] = DeviceInput(DEVICE_KEYBOARD, KEY_RIGHT); - m_EditMappingsDeviceInput.button[EDIT_BUTTON_MIDI_NOTE_NEXT][0] = DeviceInput(DEVICE_KEYBOARD, KEY_EQUAL); - m_EditMappingsDeviceInput.button[EDIT_BUTTON_MIDI_NOTE_PREV][0] = DeviceInput(DEVICE_KEYBOARD, KEY_HYPHEN); - m_EditMappingsDeviceInput.button[EDIT_BUTTON_OPEN_EDIT_MENU][0] = DeviceInput(DEVICE_KEYBOARD, KEY_ESC); m_EditMappingsMenuButton.button[EDIT_BUTTON_OPEN_EDIT_MENU][0] = GAME_BUTTON_START; m_EditMappingsMenuButton.button[EDIT_BUTTON_OPEN_EDIT_MENU][1] = GAME_BUTTON_BACK; @@ -1064,13 +1056,6 @@ void ScreenEdit::UpdateTextInfo() sText += " ...\n"; } - RString sMidiNote; - /* XXX - if( !PitchDetectionTest::MidiNoteToString( GAMESTATE->m_iEditMidiNote, sMidiNote ) ) - sMidiNote = ""; - sText += ssprintf( "%s:\n %i (%s)\n", "Pitch", (int)GAMESTATE->m_iEditMidiNote, sMidiNote.c_str() ); - */ - switch( EDIT_MODE.GetValue() ) { DEFAULT_FAIL( EDIT_MODE.GetValue() ); @@ -1412,20 +1397,6 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB ) if( m_SnapDisplay.NextSnapMode() ) OnSnapModeChange(); break; - case EDIT_BUTTON_MIDI_NOTE_NEXT: - if( GAMESTATE->m_iEditMidiNote < NUM_MIDI_NOTES-1 ) - { - GAMESTATE->m_iEditMidiNote++; - m_soundValueIncrease.Play(); - } - break; - case EDIT_BUTTON_MIDI_NOTE_PREV: - if( GAMESTATE->m_iEditMidiNote > 0 ) - { - GAMESTATE->m_iEditMidiNote--; - m_soundValueDecrease.Play(); - } - break; case EDIT_BUTTON_LAY_SELECT: { const int iCurrentRow = BeatToNoteRow(GAMESTATE->m_fSongBeat); diff --git a/src/ScreenEdit.h b/src/ScreenEdit.h index a49c811ace..fef5ba076e 100644 --- a/src/ScreenEdit.h +++ b/src/ScreenEdit.h @@ -76,9 +76,6 @@ enum EditButton EDIT_BUTTON_SNAP_NEXT, EDIT_BUTTON_SNAP_PREV, - EDIT_BUTTON_MIDI_NOTE_NEXT, - EDIT_BUTTON_MIDI_NOTE_PREV, - EDIT_BUTTON_OPEN_EDIT_MENU, EDIT_BUTTON_OPEN_AREA_MENU, EDIT_BUTTON_OPEN_BGCHANGE_LAYER1_MENU, diff --git a/src/ScreenEvaluation.cpp b/src/ScreenEvaluation.cpp index 0bf0104cc9..fa28f8fb5b 100644 --- a/src/ScreenEvaluation.cpp +++ b/src/ScreenEvaluation.cpp @@ -201,11 +201,6 @@ void ScreenEvaluation::Init() ss.m_player[p].m_radarPossible[rc] = 1 + (rand() % 200); ss.m_player[p].m_radarActual[rc] = rand() % (int)(ss.m_player[p].m_radarPossible[rc]); break; - case RadarCategory_MinMidiNote: - case RadarCategory_MaxMidiNote: - ss.m_player[p].m_radarPossible[rc] = 0; - ss.m_player[p].m_radarActual[rc] = 0; - break; } ; // filled in by ScreenGameplay on start of notes diff --git a/src/ScreenSystemLayer.cpp b/src/ScreenSystemLayer.cpp index 55b23ba50a..2abf601c67 100644 --- a/src/ScreenSystemLayer.cpp +++ b/src/ScreenSystemLayer.cpp @@ -161,36 +161,6 @@ void ScreenSystemLayer::Init() m_sprOverlay.Load( THEME->GetPathB("ScreenSystemLayer", "overlay") ); this->AddChild( m_sprOverlay ); - - /* XXX - m_quadMicBar.SetXY( SCREEN_CENTER_X, SCREEN_CENTER_Y ); - m_quadMicBar.ZoomToWidth( 4 ); - m_quadMicBar.ZoomToHeight( 400 ); - this->AddChild( &m_quadMicBar ); - - m_quadMicPos.SetXY( SCREEN_CENTER_X, SCREEN_CENTER_Y ); - m_quadMicPos.ZoomToWidth( 12 ); - m_quadMicPos.ZoomToHeight( 12 ); - this->AddChild( &m_quadMicPos ); - - m_textFreq.LoadFromFont( THEME->GetPathF("Common","Normal") ); - m_textFreq.SetXY( SCREEN_CENTER_X+100, SCREEN_CENTER_Y ); - this->AddChild( &m_textFreq ); - */ -} - -void ScreenSystemLayer::Update( float fDelta ) -{ - Screen::Update( fDelta ); - - /* XXX - const MicrophoneStatus &ms = PitchDetectionTest::s_ms; - float fYOffset = SCALE( ms.fFreq, 0.0, ms.fMaxFreq, 200, -200 ); - m_quadMicPos.SetY( SCREEN_CENTER_Y + fYOffset ); - m_quadMicPos.SetVisible( ms.bVoiced ); - PlayerState *pPS = GAMESTATE->m_pPlayerState[PLAYER_1]; - m_textFreq.SetText( ssprintf("%.3f\n%.3f\n%.3f (wrapped)\n%s", ms.fFreq, ms.fMidiNote, pPS->m_fWrappedMidiNote, ms.sMidiNote.c_str() ) ); - */ } /* diff --git a/src/ScreenSystemLayer.h b/src/ScreenSystemLayer.h index 2b5974dc31..969e487547 100644 --- a/src/ScreenSystemLayer.h +++ b/src/ScreenSystemLayer.h @@ -5,26 +5,14 @@ #include "Screen.h" #include "AutoActor.h" -/* XXX -#include "PitchDetectionTest.h" -#include "Quad.h" -#include "BitmapText.h" -*/ class ScreenSystemLayer : public Screen { public: virtual void Init(); - virtual void Update( float fDelta ); private: AutoActor m_sprOverlay; - - /* XXX - Quad m_quadMicBar; - Quad m_quadMicPos; - BitmapText m_textFreq; - */ }; diff --git a/src/Steps.cpp b/src/Steps.cpp index 517e20b840..e4349e0aea 100644 --- a/src/Steps.cpp +++ b/src/Steps.cpp @@ -1,5 +1,4 @@ -/* - * This stores a single note pattern for a song. +/* This stores a single note pattern for a song. * * We can have too much data to keep everything decompressed as NoteData, so most * songs are kept in memory compressed as SMData until requested. NoteData is normally @@ -11,8 +10,7 @@ * this yet.) * * Data can be on disk (always compressed), compressed in memory, and uncompressed in - * memory. - */ + * memory. */ #include "global.h" #include "Steps.h" #include "StepsUtil.h" @@ -275,30 +273,20 @@ void Steps::Decompress() const void Steps::Compress() const { - /* Always leave lights data uncompressed. */ + // Always leave lights data uncompressed. if( this->m_StepsType == StepsType_lights_cabinet && m_bNoteDataIsFilled ) { m_sNoteDataCompressed = RString(); return; } - /* Always leave karaoke data uncompressed. */ - if( this->m_StepsType == StepsType_karaoke_single && m_bNoteDataIsFilled ) - { - m_sNoteDataCompressed = RString(); - return; - } - if( !m_sFilename.empty() && m_LoadedFromProfile == ProfileSlot_Invalid ) { - /* - * We have a file on disk; clear all data in memory. - * - * Data on profiles can't be accessed normally (need to mount and time-out the - * device), and when we start a game and load edits, we want to be sure that - * it'll be available if the user picks it and pulls the device. Also, - * Decompress() doesn't know how to load .edits. - */ + /* We have a file on disk; clear all data in memory. + * Data on profiles can't be accessed normally (need to mount and time-out + * the device), and when we start a game and load edits, we want to be + * sure that it'll be available if the user picks it and pulls the device. + * Also, Decompress() doesn't know how to load .edits. */ m_pNoteData->Init(); m_bNoteDataIsFilled = false; @@ -308,7 +296,7 @@ void Steps::Compress() const return; } - /* We have no file on disk. Compress the data, if necessary. */ + // We have no file on disk. Compress the data, if necessary. if( m_sNoteDataCompressed.empty() ) { if( !m_bNoteDataIsFilled ) @@ -320,12 +308,12 @@ void Steps::Compress() const m_bNoteDataIsFilled = false; } -/* Copy our parent's data. This is done when we're being changed from autogen +/* Copy our parent's data. This is done when we're being changed from autogen * to normal. (needed?) */ void Steps::DeAutogen( bool bCopyNoteData ) { if( !parent ) - return; /* OK */ + return; // OK if( bCopyNoteData ) Decompress(); // fills in m_pNoteData with sliding window transform diff --git a/src/est/EST_ChannelType.h b/src/est/EST_ChannelType.h deleted file mode 100644 index 2a3265acad..0000000000 --- a/src/est/EST_ChannelType.h +++ /dev/null @@ -1,289 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /************************************************************************/ - -#ifndef __EST_CHANNELTYPE_H__ -#define __EST_CHANNELTYPE_H__ - -/**@name Channel Types - */ -//@{ - -/** Symbolic names for coefficient types. - * - * Used to record what kinds of information are in a track and - * anywhere else we need to refer to coefficient types. - * - * @see EST_ChannelType - */ - -enum EST_CoefficientType -{ - /// Linear prediction filter - cot_lpc=0, - /// guaranteed to be the first known type - cot_first=cot_lpc, - /// reflection coefficients. - cot_reflection, - /// Cepstral coefficients - cot_cepstrum, - /// Mel Scale Cepstrum - cot_melcepstrum, - /// Mel Scale filter bank - cot_fbank, - /// Line spectral pairs. - cot_lsf, - /// Tube areas for filter. - cot_tubearea, - /// Unknown filter type. - cot_filter, - /// Free for experimentation - cot_user1, - /// Free for experimentation - cot_user2, - /// Guaranteed to be one more than last legal coefficient type - cot_free -}; - -/**@name Channel Type Numbering Scheme - * - * Channel types are given numbers containing the following information: - * \begin{itemize} - * \item A numeric index. - * \item A Number of differentiations 0-2 - * \item 0 for start, 1 for end - * \end{itemize} - * Things which do not require all these features are packed in according - * to the following rules: - * \begin{itemize} - * \item Single values which can be differentiated are paired as - * if they were start and end positions of an unknown type - * of coefficient. - * \item Single values which can't be differentiated are put in the - * positions where the 3rd derivatives would logically be - * found. - * \end{itemize} - */ -//@{ - -/// extract the coefficient type -#define EST_ChannelTypeCT(T) ( (T) >> 3 ) -/// extract the number of differentiations -#define EST_ChannelTypeD(T) ( (T) >> 1 & 3 ) -/// extract the start/end flag. -#define EST_ChannelTypeSE(T) ( (T) & 1 ) - -/// get start from end -#define EST_ChannelTypeStart(T) EST_CoefChannelId(\ - EST_ChannelTypeCT(T), \ - EST_ChannelTypeD(T), \ - 0) -/// get end from start -#define EST_ChannelTypeEnd(T) EST_CoefChannelId(\ - EST_ChannelTypeCT(T), \ - EST_ChannelTypeD(T), \ - 1) -/// differentiate once -#define EST_ChannelTypeIncD(T) EST_CoefChannelId(\ - EST_ChannelTypeCT(T), \ - EST_ChannelTypeD(T)+1, \ - EST_ChannelTypeSE(T)) -/// differentiate N times -#define EST_ChannelTypeDelta(T, N) EST_CoefChannelId(\ - EST_ChannelTypeCT(T), \ - EST_ChannelTypeD(T)+(N), \ - EST_ChannelTypeSE(T)) -/// integrate once -#define EST_ChannelTypeDecD(T) EST_CoefChannelId(\ - EST_ChannelTypeCT(T), \ - EST_ChannelTypeD(T)-1, \ - EST_ChannelTypeSE(T)) - - -/** Build a number representing a channel type for a coefficient type. - * - * CT = coefficient type - * D = Number of levels of differentiation. - * SE = Start=0 end=1 - */ -#define EST_CoefChannelId(CT,D,SE) ( (CT)<<3 | (D)<<1 & 6 | (SE)&1 ) - -/** Build a number representing a channel type for a single value which can - * N = count starting from 0 - * D = Number of levels of differentiation. - * be differentiated. - */ - -#define EST_DiffChannelId(N,D) ( EST_CoefChannelId(((N)>>1)+(int)cot_free, D, (N)&1) ) - -/** Build a number representing a channel type for a simple value - * such as length or voicing probability. - */ - -#define EST_ChannelId(N) EST_CoefChannelId((N)>>1, 3, (N)&1) -//@} - - -/** Symbolic names for track channels. - * Used in track maps to label channels so they can be accessed without - * knowing exactly where in the track they are. - * - * @see EST_CoefficientType - * @see EST_TrackMap - * @see EST_Track - * @see EST_TrackMap:example - * @author Richard Caley - * @version $Id: EST_ChannelType.h,v 1.3 2004/05/04 00:00:16 awb Exp $ - */ - -enum EST_ChannelType { - /// Value to return for errors, never occurs in TrackMaps - channel_unknown = EST_ChannelId(0), - /// order of analysis. - channel_order = EST_ChannelId(1), - /// So we know how many there are - first_channel_type=channel_order, - /// Peak amplitude. - channel_peak = EST_ChannelId(2), - /// Duration of section of signal. - channel_duration = EST_ChannelId(3), - /// Length of section in samples. - channel_length = EST_ChannelId(4), - /// Offset from frame center to center of window - channel_offset = EST_ChannelId(5), - /// Voicing decision. - channel_voiced = EST_ChannelId(6), - /// Number of related frame in another track. - channel_frame = EST_ChannelId(7), - /// Time in seconds this frame refers to. - channel_time = EST_ChannelId(8), - - /// RMS power of section of signal. - channel_power = EST_DiffChannelId(0,0), - channel_power_d = EST_DiffChannelId(0,1), - channel_power_a = EST_DiffChannelId(0,2), - /// RMS energy of section of signal. - channel_energy = EST_DiffChannelId(1,0), - channel_energy_d = EST_DiffChannelId(1,1), - channel_energy_a = EST_DiffChannelId(1,2), - /// F0 in Hz. - channel_f0 = EST_DiffChannelId(2,0), - channel_f0_d = EST_DiffChannelId(2,1), - channel_f0_a = EST_DiffChannelId(2,2), - - channel_lpc_0 = EST_CoefChannelId(cot_lpc,0,0), - channel_lpc_N = EST_CoefChannelId(cot_lpc,0,1), - channel_lpc_d_0 = EST_CoefChannelId(cot_lpc,1,0), - channel_lpc_d_N = EST_CoefChannelId(cot_lpc,1,1), - channel_lpc_a_0 = EST_CoefChannelId(cot_lpc,2,0), - channel_lpc_a_N = EST_CoefChannelId(cot_lpc,2,1), - - channel_reflection_0 = EST_CoefChannelId(cot_reflection,0,0), - channel_reflection_N = EST_CoefChannelId(cot_reflection,0,1), - channel_reflection_d_0 = EST_CoefChannelId(cot_reflection,1,0), - channel_reflection_d_N = EST_CoefChannelId(cot_reflection,1,1), - channel_reflection_a_0 = EST_CoefChannelId(cot_reflection,2,0), - channel_reflection_a_N = EST_CoefChannelId(cot_reflection,2,1), - - - channel_cepstrum_0 = EST_CoefChannelId(cot_cepstrum,0,0), - channel_cepstrum_N = EST_CoefChannelId(cot_cepstrum,0,1), - channel_cepstrum_d_0 = EST_CoefChannelId(cot_cepstrum,1,0), - channel_cepstrum_d_N = EST_CoefChannelId(cot_cepstrum,1,1), - channel_cepstrum_a_0 = EST_CoefChannelId(cot_cepstrum,2,0), - channel_cepstrum_a_N = EST_CoefChannelId(cot_cepstrum,2,1), - - - channel_melcepstrum_0 = EST_CoefChannelId(cot_melcepstrum,0,0), - channel_melcepstrum_N = EST_CoefChannelId(cot_melcepstrum,0,1), - channel_melcepstrum_d_0 = EST_CoefChannelId(cot_melcepstrum,1,0), - channel_melcepstrum_d_N = EST_CoefChannelId(cot_melcepstrum,1,1), - channel_melcepstrum_a_0 = EST_CoefChannelId(cot_melcepstrum,2,0), - channel_melcepstrum_a_N = EST_CoefChannelId(cot_melcepstrum,2,1), - - channel_fbank_0 = EST_CoefChannelId(cot_fbank,0,0), - channel_fbank_N = EST_CoefChannelId(cot_fbank,0,1), - channel_fbank_d_0 = EST_CoefChannelId(cot_fbank,1,0), - channel_fbank_d_N = EST_CoefChannelId(cot_fbank,1,1), - channel_fbank_a_0 = EST_CoefChannelId(cot_fbank,2,0), - channel_fbank_a_N = EST_CoefChannelId(cot_fbank,2,1), - - - channel_lsf_0 = EST_CoefChannelId(cot_lsf,0,0), - channel_lsf_N = EST_CoefChannelId(cot_lsf,0,1), - channel_lsf_d_0 = EST_CoefChannelId(cot_lsf,1,0), - channel_lsf_d_N = EST_CoefChannelId(cot_lsf,1,1), - channel_lsf_a_0 = EST_CoefChannelId(cot_lsf,2,0), - channel_lsf_a_N = EST_CoefChannelId(cot_lsf,2,1), - - - channel_tubearea_0 = EST_CoefChannelId(cot_tubearea,0,0), - channel_tubearea_N = EST_CoefChannelId(cot_tubearea,0,1), - channel_tubearea_d_0 = EST_CoefChannelId(cot_tubearea,1,0), - channel_tubearea_d_N = EST_CoefChannelId(cot_tubearea,1,1), - channel_tubearea_a_0 = EST_CoefChannelId(cot_tubearea,2,0), - channel_tubearea_a_N = EST_CoefChannelId(cot_tubearea,2,1), - - - channel_filter_0 = EST_CoefChannelId(cot_filter,0,0), - channel_filter_N = EST_CoefChannelId(cot_filter,0,1), - channel_filter_d_0 = EST_CoefChannelId(cot_filter,1,0), - channel_filter_d_N = EST_CoefChannelId(cot_filter,1,1), - channel_filter_a_0 = EST_CoefChannelId(cot_filter,2,0), - channel_filter_a_N = EST_CoefChannelId(cot_filter,2,1), - - - channel_user1_0 = EST_CoefChannelId(cot_user1,0,0), - channel_user1_N = EST_CoefChannelId(cot_user1,0,1), - channel_user1_d_0 = EST_CoefChannelId(cot_user1,1,0), - channel_user1_d_N = EST_CoefChannelId(cot_user1,1,1), - channel_user1_a_0 = EST_CoefChannelId(cot_user1,2,0), - channel_user1_a_N = EST_CoefChannelId(cot_user1,2,1), - - - channel_user2_0 = EST_CoefChannelId(cot_user2,0,0), - channel_user2_N = EST_CoefChannelId(cot_user2,0,1), - channel_user2_d_0 = EST_CoefChannelId(cot_user2,1,0), - channel_user2_d_N = EST_CoefChannelId(cot_user2,1,1), - channel_user2_a_0 = EST_CoefChannelId(cot_user2,2,0), - channel_user2_a_N = EST_CoefChannelId(cot_user2,2,1), - - - - last_channel_type = channel_f0_a, - /// Can be used to size arrays etc. - num_channel_types -}; -//@} -typedef enum EST_ChannelType EST_ChannelType; - -#endif diff --git a/src/est/EST_Chunk.h b/src/est/EST_Chunk.h deleted file mode 100644 index eb9be9e94d..0000000000 --- a/src/est/EST_Chunk.h +++ /dev/null @@ -1,251 +0,0 @@ - - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /************************************************************************/ - /* */ - /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */ - /* Date: February 1997 */ - /* -------------------------------------------------------------------- */ - /* */ - /* Use counted memory chunks and smart pointers to them. */ - /* */ - /************************************************************************/ - -#if ! defined(__EST_CHUNK_H__) -#define __EST_CHUNK_H__ - -#ifdef HAVE_CONFIG_H -# include "est_string_config.h" -#else -# define HAVE_WALLOC_H (1) -#endif - -#include -#include -#include - -// Warn when getting a writable version of a shared chunk -- -// useful for minimising copies. - -#define __INCLUDE_CHUNK_WARNINGS__ (1) - -#if defined(__INCULDE_CHUNK_WARNINGS__) -# define CHUNK_WARN(WHAT) do { cerr << "chunk: " <size:0; }; - int shareing(void) const { return ptr?(ptr->count >1):0; }; - int count(void) const { return ptr?(ptr->count):-1; }; - - EST_ChunkPtr &operator = (EST_ChunkPtr cp) CII({ - // doing it in this order means self assignment is safe. - if (cp.ptr) - ++ *(cp.ptr); - if (ptr) - -- *ptr; - ptr=cp.ptr; - return *this; - }); - - // If they manage to get hold of one... - // Actually usually used to assign NULL and so (possibly) deallocate - // the chunk currently pointed to. - EST_ChunkPtr &operator = (EST_Chunk *chp) CII({ - // doing it in this order means self assignment is safe. - if (chp) - ++ *chp; - if (ptr) - -- *ptr; - ptr=chp; - return *this; - }); - - // Casting to a non-const pointer causes a - // warning to stderr if the chunk is shared. - operator char*() CII({ - if (ptr && ptr->count > 1) - { - CHUNK_WARN("getting writable version of shared chunk\n"); - make_updatable(*this); - } - return ptr?&(ptr->memory[0]):(char *)NULL; - }); - operator const char*() const CII({ - return ptr?&(ptr->memory[0]):(const char *)NULL; - }); - operator const char*() CII({ - return ptr?&(ptr->memory[0]):(const char *)NULL; - }); - - - const char operator [] (int i) const { return ptr->memory[i]; }; - char &operator () (int i) CII({ - if (ptr->count>1) - { - CHUNK_WARN("getting writable version of shared chunk\n"); - make_updatable(*this); - } - return ptr->memory[i]; - }); - - // Creating a new one - friend EST_ChunkPtr chunk_allocate(int size); - friend EST_ChunkPtr chunk_allocate(int bytes, const char *initial, int initial_len); - friend EST_ChunkPtr chunk_allocate(int bytes, const EST_ChunkPtr &initial, int initial_start, int initial_len); - - // Make sure the memory isn`t shared. - friend void make_updatable(EST_ChunkPtr &shared, EST_Chunk::EST_chunk_size inuse); - friend void make_updatable(EST_ChunkPtr &shared); - - // Make sure there is enough room (also makes updatable) - friend void grow_chunk(EST_ChunkPtr &shared, EST_Chunk::EST_chunk_size inuse, EST_Chunk::EST_chunk_size newsize); - friend void grow_chunk(EST_ChunkPtr &shared, EST_Chunk::EST_chunk_size newsize); - - // we print it by just printing the chunk - friend ostream &operator << (ostream &s, const EST_ChunkPtr &cp) { return (s<< *cp.ptr); }; - - friend void tester(void); -}; - -#endif diff --git a/src/est/EST_Contents.h b/src/est/EST_Contents.h deleted file mode 100644 index d79740da60..0000000000 --- a/src/est/EST_Contents.h +++ /dev/null @@ -1,98 +0,0 @@ -/*************************************************************************/ -/* */ -/* Centre for Speech Technology Research */ -/* University of Edinburgh, UK */ -/* Copyright (c) 1995,1996 */ -/* All Rights Reserved. */ -/* */ -/* Permission is hereby granted, free of charge, to use and distribute */ -/* this software and its documentation without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of this work, and to */ -/* permit persons to whom this work is furnished to do so, subject to */ -/* the following conditions: */ -/* 1. The code must retain the above copyright notice, this list of */ -/* conditions and the following disclaimer. */ -/* 2. Any modifications must be clearly marked as such. */ -/* 3. Original authors' names are not deleted. */ -/* 4. The authors' names are not used to endorse or promote products */ -/* derived from this software without specific prior written */ -/* permission. */ -/* */ -/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ -/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ -/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ -/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ -/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ -/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ -/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ -/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ -/* THIS SOFTWARE. */ -/* */ -/*************************************************************************/ -/* Author : Alan W Black */ -/* Date : May 1996 */ -/*-----------------------------------------------------------------------*/ -/* A class for representing ints floats and strings */ -/* */ -/*=======================================================================*/ -#ifndef __EST_CONTENTS_H__ -#define __EST_CONTENTS_H__ - -/** A class for containing some other (arbitrary) class - Not general enough to call itself a run-time type system - Is designed to solve the problem of holding user - specified information. - Keeps reference count to know when to delete contents - - This is done on two levels EST_Contents and Contents_Data -*/ -class EST_Content_Data{ - private: - int refs; - void *data; - void (*free_func)(void *data); - public: - EST_Content_Data(void *d,void (*f)(void *d)) {free_func=f; data=d; refs=1;} - ~EST_Content_Data() { free_func(data); } - /// - int unref() { return --refs; } - /// - int ref() { return ++refs; } - /// - int the_refs() { return refs; } - void *contents() { return data; } - EST_Content_Data &operator=(const EST_Content_Data &c) - {refs = c.refs; data = c.data; free_func = free_func; return *this;} -}; - -/** More contents */ - -class EST_Contents{ -private: - EST_Content_Data *content_data; - void unref_contents(void) - { if ((content_data != 0) && - (content_data->unref() == 0)) - delete content_data;} -public: - EST_Contents() { content_data = 0; } - EST_Contents(void *p,void (*free_func)(void *p)) - { content_data = new EST_Content_Data(p,free_func); } - ~EST_Contents() { unref_contents(); } - void set_contents(void *p,void (*free_func)(void *p)) - { unref_contents(); content_data = new EST_Content_Data(p,free_func);} - void *get_contents() const - {return (content_data ? content_data->contents() : 0);} - /// - int refs() const { return ((content_data == 0) ? 0 : - content_data->the_refs());} - EST_Contents &operator=(const EST_Contents &c) - { unref_contents(); - content_data = c.content_data; - if (content_data != 0) content_data->ref(); - return *this; } -}; - -#endif - diff --git a/src/est/EST_DMatrix.h b/src/est/EST_DMatrix.h deleted file mode 100644 index a9e6733918..0000000000 --- a/src/est/EST_DMatrix.h +++ /dev/null @@ -1,237 +0,0 @@ -/*************************************************************************/ -/* */ -/* Centre for Speech Technology Research */ -/* University of Edinburgh, UK */ -/* Copyright (c) 1996 */ -/* All Rights Reserved. */ -/* */ -/* Permission is hereby granted, free of charge, to use and distribute */ -/* this software and its documentation without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of this work, and to */ -/* permit persons to whom this work is furnished to do so, subject to */ -/* the following conditions: */ -/* 1. The code must retain the above copyright notice, this list of */ -/* conditions and the following disclaimer. */ -/* 2. Any modifications must be clearly marked as such. */ -/* 3. Original authors' names are not deleted. */ -/* 4. The authors' names are not used to endorse or promote products */ -/* derived from this software without specific prior written */ -/* permission. */ -/* */ -/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ -/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ -/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ -/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ -/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ -/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ -/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ -/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ -/* THIS SOFTWARE. */ -/* */ -/*************************************************************************/ -/* */ -/* Author : Simon King */ -/* Date : February 1999 */ -/* --------------------------------------------------------------------- */ -/* Double matrix class - copied from FMatrix ! */ -/* */ -/*************************************************************************/ - -#ifndef __DMatrix_H__ -#define __DMatrix_H__ - -#include "EST_TSimpleMatrix.h" -#include "EST_TSimpleVector.h" -#include "EST_FMatrix.h" - - -class EST_DVector; - -/** A matrix class for double precision floating point numbers. -EST_DMatrix x should be used instead of double **x wherever -possible.*/ -class EST_DMatrix : public EST_TSimpleMatrix { -private: -public: - /// size constructor - EST_DMatrix(int m, int n):EST_TSimpleMatrix(m, n) {} - /// copy constructor - EST_DMatrix(const EST_DMatrix &a):EST_TSimpleMatrix(a) {} - - static EST_String default_file_type; - /// CHECK - what does this do??? - EST_DMatrix(const EST_DMatrix &a, int b); - /// default constructor - EST_DMatrix():EST_TSimpleMatrix() {} - - /// Save in file (ascii or binary) - EST_write_status save(const EST_String &filename, - const EST_String &type = - EST_DMatrix::default_file_type); - /// Load from file (ascii or binary as defined in file) - EST_read_status load(const EST_String &filename); - /// Save in file in est format - EST_write_status est_save(const EST_String &filename, - const EST_String &type); - /// Load from file in est format (binary/ascii defined in file itself) - EST_read_status est_load(const EST_String &filename); - - /// Copy 2-d array {\tt x} of size {\tt rows x cols} into matrix. - void copyin(double **x, int rows, int cols); - - /// Add elements of 2 same sized matrices. - EST_DMatrix &operator+=(const EST_DMatrix &a); - - /// Subtract elements of 2 same sized matrices. - EST_DMatrix &operator-=(const EST_DMatrix &a); - - /// elementwise multiply by scalar - EST_DMatrix &operator*=(const double f); - - /// elementwise divide by scalar - EST_DMatrix &operator/=(const double f); - - /// Multiply all elements of matrix by {\tt x}. - friend EST_DMatrix operator*(const EST_DMatrix &a, const double x); - - /// Multiply matrix by vector. - friend EST_DVector operator*(const EST_DMatrix &a, const EST_DVector &v); - - /// Multiply vector by matrix - friend EST_DVector operator*(const EST_DVector &v,const EST_DMatrix &a); - - /// Multiply matrix by matrix. - friend EST_DMatrix operator*(const EST_DMatrix &a, const EST_DMatrix &b); -}; - - -/** A vector class for double precision floating point - numbers. {\tt EST_DVector x} should be used instead of - {\tt float *x} wherever possible. -*/ -class EST_DVector: public EST_TSimpleVector { -public: - /// Size constructor. - EST_DVector(int n): EST_TSimpleVector(n) {} - /// Copy constructor. - EST_DVector(const EST_DVector &a): EST_TSimpleVector(a) {} - /// Default constructor. - EST_DVector(): EST_TSimpleVector() {} - - /// elementwise multiply - EST_DVector &operator*=(const EST_DVector &s); - - /// elementwise add - EST_DVector &operator+=(const EST_DVector &s); - - /// elementwise multiply by scalar - EST_DVector &operator*=(const double d); - - /// elementwise divide by scalar - EST_DVector &operator/=(const double d); - - EST_write_status est_save(const EST_String &filename, - const EST_String &type); - - /// save vector to file filename. - EST_write_status save(const EST_String &filename, - const EST_String &type); - - /// load vector from file filename. - EST_read_status load(const EST_String &filename); - /// Load from file in est format (binary/ascii defined in file itself) - EST_read_status est_load(const EST_String &filename); -}; - -int square(const EST_DMatrix &a); -/// inverse -int inverse(const EST_DMatrix &a, EST_DMatrix &inv); -int inverse(const EST_DMatrix &a, EST_DMatrix &inv, int &singularity); -/// pseudo inverse (for non-square matrices) -int pseudo_inverse(const EST_DMatrix &a, EST_DMatrix &inv); -int pseudo_inverse(const EST_DMatrix &a, EST_DMatrix &inv,int &singularity); - -/// some useful matrix creators -/// make an identity matrix of dimension n -void eye(EST_DMatrix &a, const int n); -/// make already square matrix into I without resizing -void eye(EST_DMatrix &a); - -/// the user should use est_seed to seed the random number generator -void est_seed(); -void est_seed48(); -/// all elements are randomised -void make_random_vector(EST_DVector &M, const double scale); -/// all elements are randomised -void make_random_matrix(EST_DMatrix &M, const double scale); -/// used for variance -void make_random_diagonal_matrix(EST_DMatrix &M, const double scale); -/// used for covariance -void make_random_symmetric_matrix(EST_DMatrix &M, const double scale); - -void make_poly_basis_function(EST_DMatrix &T, EST_DVector t); - -/// elementwise add -EST_DVector add(const EST_DVector &a,const EST_DVector &b); -/// elementwise subtract -EST_DVector subtract(const EST_DVector &a,const EST_DVector &b); - -/// enforce symmetry -void symmetrize(EST_DMatrix &a); -/// stack columns on top of each other to make a vector -void stack_matrix(const EST_DMatrix &M, EST_DVector &v); -/// inplace diagonalise -void inplace_diagonalise(EST_DMatrix &a); - - -double determinant(const EST_DMatrix &a); -/// not implemented ?? -int singular(EST_DMatrix &a); -/// exchange rows and columns -void transpose(const EST_DMatrix &a,EST_DMatrix &b); -EST_DMatrix triangulate(const EST_DMatrix &a); - -/// extract leading diagonal as a matrix -EST_DMatrix diagonalise(const EST_DMatrix &a); -/// extract leading diagonal as a vector -EST_DVector diagonal(const EST_DMatrix &a); -/// sum of elements -double sum(const EST_DMatrix &a); -void multiply(const EST_DMatrix &a, const EST_DMatrix &b, EST_DMatrix &c); -int floor_matrix(EST_DMatrix &M, const double floor); - -/// matrix product of two vectors (#rows = length of first vector, #cols = length of second vector) -EST_DMatrix cov_prod(const EST_DVector &v1,const EST_DVector &v2); - -EST_DMatrix operator*(const EST_DMatrix &a, const EST_DMatrix &b); -EST_DMatrix operator-(const EST_DMatrix &a, const EST_DMatrix &b); -EST_DMatrix operator+(const EST_DMatrix &a, const EST_DMatrix &b); - -EST_DVector operator-(const EST_DVector &a, const EST_DVector &b); -EST_DVector operator+(const EST_DVector &a, const EST_DVector &b); - -EST_DMatrix sub(const EST_DMatrix &a, int row, int col); -EST_DMatrix DMatrix_abs(const EST_DMatrix &a); - -EST_DMatrix row(const EST_DMatrix &a, int row); -EST_DMatrix column(const EST_DMatrix &a, int col); - - -/// least squares fit -bool -polynomial_fit(EST_DVector &x, EST_DVector &y, EST_DVector &co_effs, int order); - -/// weighted least squares fit -bool -polynomial_fit(EST_DVector &x, EST_DVector &y, EST_DVector &co_effs, - EST_DVector &weights, int order); - -double -polynomial_value(const EST_DVector &coeffs, const double x); - -/// vector dot product -double operator*(const EST_DVector &v1, const EST_DVector &v2); - - -#endif diff --git a/src/est/EST_FMatrix.h b/src/est/EST_FMatrix.h deleted file mode 100644 index 1c78403df4..0000000000 --- a/src/est/EST_FMatrix.h +++ /dev/null @@ -1,246 +0,0 @@ - /*************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - /* */ - /* Author : Paul Taylor */ - /* Date : April 1996 */ - /* --------------------------------------------------------------------- */ - /* Matrix class */ - /* */ - /*************************************************************************/ - -#ifndef __FMatrix_H__ -#define __FMatrix_H__ - -#include "EST_TSimpleMatrix.h" -#include "EST_TSimpleVector.h" - -#include "EST_Val.h" -#include "EST_Val_defs.h" - -class EST_FVector; - -/** A matrix class for floating point numbers. EST_FMatrix x should be - used instead of float **x wherever possible. -*/ - -class EST_FMatrix : public EST_TSimpleMatrix { -private: -public: - /// size constructor - EST_FMatrix(int m, int n):EST_TSimpleMatrix(m, n) {} - /// copy constructor - EST_FMatrix(const EST_FMatrix &a):EST_TSimpleMatrix(a) {} - - static EST_String default_file_type; - /// CHECK - what does this do??? - EST_FMatrix(const EST_FMatrix &a, int b); - /// default constructor - EST_FMatrix():EST_TSimpleMatrix() {} - - /// Save in file (ascii or binary) - EST_write_status save(const EST_String &filename, - const EST_String &type = - EST_FMatrix::default_file_type ); - /// Load from file (ascii or binary as defined in file) - EST_read_status load(const EST_String &filename); - /// Save in file in est format - EST_write_status est_save(const EST_String &filename, - const EST_String &type); - /// Load from file in est format (binary/ascii defined in file itself) - EST_read_status est_load(const EST_String &filename); - - /// Copy 2-d array {\tt x} of size {\tt rows x cols} into matrix. - void copyin(float **x, int rows, int cols); - - /// Add elements of 2 same sized matrices. - EST_FMatrix &operator+=(const EST_FMatrix &a); - - /// Subtract elements of 2 same sized matrices. - EST_FMatrix &operator-=(const EST_FMatrix &a); - - /// elementwise multiply by scalar - EST_FMatrix &operator*=(const float f); - - /// elementwise divide by scalar - EST_FMatrix &operator/=(const float f); - - /// Multiply all elements of matrix by {\tt x}. - friend EST_FMatrix operator*(const EST_FMatrix &a, const float x); - - /// Multiply matrix by vector. - friend EST_FVector operator*(const EST_FMatrix &a, const EST_FVector &v); - - /// Multiply vector by matrix - friend EST_FVector operator*(const EST_FVector &v,const EST_FMatrix &a); - - /// Multiply matrix by matrix. - friend EST_FMatrix operator*(const EST_FMatrix &a, const EST_FMatrix &b); -}; - -/** A vector class for floating point numbers. - {\tt EST_FVector x} should be used instead of {\tt float *x} - wherever possible. -*/ -class EST_FVector: public EST_TSimpleVector { -public: - /// Size constructor. - EST_FVector(int n): EST_TSimpleVector(n) {} - /// Copy constructor. - EST_FVector(const EST_FVector &a): EST_TSimpleVector(a) {} - /// Default constructor. - EST_FVector(): EST_TSimpleVector() {} - - /// elementwise multiply - EST_FVector &operator*=(const EST_FVector &s); - - /// elementwise add - EST_FVector &operator+=(const EST_FVector &s); - - /// elementwise multiply by scalar - EST_FVector &operator*=(const float f); - - /// elementwise divide by scalar - EST_FVector &operator/=(const float f); - - EST_write_status est_save(const EST_String &filename, - const EST_String &type); - - /// save vector to file filename. - EST_write_status save(const EST_String &filename, - const EST_String &type); - - /// load vector from file filename. - EST_read_status load(const EST_String &filename); - /// Load from file in est format (binary/ascii defined in file itself) - EST_read_status est_load(const EST_String &filename); - -}; - -/// find largest element -float matrix_max(const EST_FMatrix &a); -/// find largest element -float vector_max(const EST_FVector &a); - -int square(const EST_FMatrix &a); -/// inverse -int inverse(const EST_FMatrix &a, EST_FMatrix &inv); -int inverse(const EST_FMatrix &a, EST_FMatrix &inv, int &singularity); -/// pseudo inverse (for non-square matrices) -int pseudo_inverse(const EST_FMatrix &a, EST_FMatrix &inv); -int pseudo_inverse(const EST_FMatrix &a, EST_FMatrix &inv,int &singularity); - -/// some useful matrix creators -/// make an identity matrix of dimension n -void eye(EST_FMatrix &a, const int n); -/// make already square matrix into I without resizing -void eye(EST_FMatrix &a); - -/// the user should use est_seed to seed the random number generator -void est_seed(); -void est_seed48(); -/// all elements are randomised -void make_random_vector(EST_FVector &M, const float scale); -/// all elements are randomised -void make_random_matrix(EST_FMatrix &M, const float scale); -/// used for variance -void make_random_diagonal_matrix(EST_FMatrix &M, const float scale); -/// used for covariance -void make_random_symmetric_matrix(EST_FMatrix &M, const float scale); - -void make_poly_basis_function(EST_FMatrix &T, EST_FVector t); - -/// elementwise add -EST_FVector add(const EST_FVector &a,const EST_FVector &b); -/// elementwise subtract -EST_FVector subtract(const EST_FVector &a,const EST_FVector &b); - -/// enforce symmetry -void symmetrize(EST_FMatrix &a); -/// stack columns on top of each other to make a vector -void stack_matrix(const EST_FMatrix &M, EST_FVector &v); -/// inplace diagonalise -void inplace_diagonalise(EST_FMatrix &a); - - -float determinant(const EST_FMatrix &a); -/// not implemented ?? -int singular(EST_FMatrix &a); -/// exchange rows and columns -void transpose(const EST_FMatrix &a,EST_FMatrix &b); -EST_FMatrix triangulate(const EST_FMatrix &a); - -/// extract leading diagonal as a matrix -EST_FMatrix diagonalise(const EST_FMatrix &a); -/// extract leading diagonal as a vector -EST_FVector diagonal(const EST_FMatrix &a); -/// sum of elements -float sum(const EST_FMatrix &a); -void multiply(const EST_FMatrix &a, const EST_FMatrix &b, EST_FMatrix &c); -int floor_matrix(EST_FMatrix &M, const float floor); - -/// matrix product of two vectors (#rows = length of first vector, #cols = length of second vector) -EST_FMatrix cov_prod(const EST_FVector &v1,const EST_FVector &v2); - -EST_FMatrix operator*(const EST_FMatrix &a, const EST_FMatrix &b); -EST_FMatrix operator-(const EST_FMatrix &a, const EST_FMatrix &b); -EST_FMatrix operator+(const EST_FMatrix &a, const EST_FMatrix &b); - -EST_FVector operator-(const EST_FVector &a, const EST_FVector &b); -EST_FVector operator+(const EST_FVector &a, const EST_FVector &b); - -EST_FMatrix sub(const EST_FMatrix &a, int row, int col); -EST_FMatrix fmatrix_abs(const EST_FMatrix &a); - -EST_FMatrix row(const EST_FMatrix &a, int row); -EST_FMatrix column(const EST_FMatrix &a, int col); - - -/// least squares fit -bool -polynomial_fit(EST_FVector &x, EST_FVector &y, EST_FVector &co_effs, int order); - -/// weighted least squares fit -bool -polynomial_fit(EST_FVector &x, EST_FVector &y, EST_FVector &co_effs, - EST_FVector &weights, int order); - -float -polynomial_value(const EST_FVector &coeffs, const float x); - -/// vector dot product -float operator*(const EST_FVector &v1, const EST_FVector &v2); - -VAL_REGISTER_CLASS_DCLS(fmatrix,EST_FMatrix) -VAL_REGISTER_CLASS_DCLS(fvector,EST_FVector) - -#endif diff --git a/src/est/EST_Featured.h b/src/est/EST_Featured.h deleted file mode 100644 index 08739312ce..0000000000 --- a/src/est/EST_Featured.h +++ /dev/null @@ -1,162 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - - -#ifndef __EST_FEATURED_H__ -#define __EST_FEATURED_H__ - - -#include "EST_Features.h" - -/** A class with the mechanisms needed to give an object features and - * access them nicely. Used as a parent class. - * - * @author Richard Caley - * @version $Id: EST_Featured.h,v 1.3 2004/05/04 00:00:16 awb Exp $ */ - -class EST_Featured { -private: - - EST_Features *p_features; - -protected: - - EST_Featured(void); - EST_Featured(const EST_Featured &f); - ~EST_Featured(void); - - void init_features(); - - void copy_features(const EST_Featured &f); - - void clear_features(); - - void ensure_features(void) - { if (p_features==NULL) p_features= new EST_Features; } - -public: - - int f_Int(const char *name, int def) const - { return p_features?p_features->I(name, def):def; } - int f_Int(const char *name) const - { return p_features?p_features->I(name):0; } - int f_I(const char *name, int def) const - {return f_Int(name, def);} - int f_I(const char *name) const - {return f_Int(name);} - void f_set(const EST_String name, int val) - { ensure_features(); p_features->set(name, val); } - void f_set_path(const EST_String name, int val) - { ensure_features(); p_features->set_path(name, val); } - - - float f_Float(const char *name, float def) const - { return p_features?p_features->F(name, def):def; } - float f_Float(const char *name) const - { return p_features?p_features->F(name):0.0; } - float f_F(const char *name, float def) const - {return f_Float(name, def);} - float f_F(const char *name) const - {return f_Float(name);} - void f_set(const EST_String name, float val) - { ensure_features(); p_features->set(name, val); } - void f_set_path(const EST_String name, float val) - { ensure_features(); p_features->set_path(name, val); } - - - EST_String f_String(const char *name, const EST_String &def) const - { return p_features?p_features->S(name, def):def; } - EST_String f_String(const char *name) const - { return p_features?p_features->S(name):EST_String::Empty; } - EST_String f_S(const char *name, const EST_String &def) const - {return f_String(name, def);} - EST_String f_S(const char *name) const - {return f_String(name);} - void f_set(const EST_String name, const char *val) - { ensure_features(); p_features->set(name, val); } - void f_set_path(const EST_String name, const char *val) - { ensure_features(); p_features->set_path(name, val); } - - - const EST_Val &f_Val(const char *name, const EST_Val &def) const; - const EST_Val &f_Val(const char *name) const; - - const EST_Val &f_V(const char *name, const EST_Val &def) const - {return f_Val(name, def);} - const EST_Val &f_V(const char *name) const - {return f_Val(name);} - void f_set_val(const EST_String name, EST_Val val) - { ensure_features(); p_features->set_val(name, val); } - void f_set_path(const EST_String name, EST_Val val) - { ensure_features(); p_features->set_path(name, val); } - - void f_set(const EST_Features &f) - { ensure_features(); *p_features = f; } - - int f_present(const EST_String name) const - {return p_features && p_features->present(name); } - - void f_remove(const EST_String name) - { if (p_features) p_features->remove(name); } - - // iteration - - protected: - struct IPointer_feat { EST_Features::RwEntries i; }; -// struct IPointer_feat { EST_TRwStructIterator< EST_Features, EST_Features::IPointer, EST_Features::Entry> i; }; - - void point_to_first(IPointer_feat &ip) const - { if (p_features) ip.i.begin(*p_features);} - void move_pointer_forwards(IPointer_feat &ip) const - { ++(ip.i); } - bool points_to_something(const IPointer_feat &ip) const - { return ip.i != 0; } - EST_TKVI &points_at(const IPointer_feat &ip) - { return *(ip.i); } - - friend class EST_TIterator< EST_Featured, IPointer_feat, EST_TKVI >; - friend class EST_TStructIterator< EST_Featured, IPointer_feat, EST_TKVI >; - friend class EST_TRwIterator< EST_Featured, IPointer_feat, EST_TKVI >; - friend class EST_TRwStructIterator< EST_Featured, IPointer_feat, EST_TKVI >; - -public: - typedef EST_TKVI FeatEntry; - typedef EST_TStructIterator< EST_Featured, IPointer_feat, FeatEntry> FeatEntries; - typedef EST_TRwStructIterator< EST_Featured, IPointer_feat, FeatEntry> RwFeatEntries; - - - -}; - -#endif - diff --git a/src/est/EST_Features.h b/src/est/EST_Features.h deleted file mode 100644 index 6fbbd4bcfe..0000000000 --- a/src/est/EST_Features.h +++ /dev/null @@ -1,330 +0,0 @@ -/*************************************************************************/ -/* */ -/* Centre for Speech Technology Research */ -/* University of Edinburgh, UK */ -/* Copyright (c) 1998 */ -/* All Rights Reserved. */ -/* */ -/* Permission is hereby granted, free of charge, to use and distribute */ -/* this software and its documentation without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of this work, and to */ -/* permit persons to whom this work is furnished to do so, subject to */ -/* the following conditions: */ -/* 1. The code must retain the above copyright notice, this list of */ -/* conditions and the following disclaimer. */ -/* 2. Any modifications must be clearly marked as such. */ -/* 3. Original authors' names are not deleted. */ -/* 4. The authors' names are not used to endorse or promote products */ -/* derived from this software without specific prior written */ -/* permission. */ -/* */ -/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ -/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ -/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ -/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ -/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ -/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ -/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ -/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ -/* THIS SOFTWARE. */ -/* */ -/*************************************************************************/ -/* Author : Alan W Black */ -/* Date : March 1998 */ -/*-----------------------------------------------------------------------*/ -/* A class for feature value pairs */ -/*=======================================================================*/ -#ifndef __EST_FEATURES_H__ -#define __EST_FEATURES_H__ - -#include "EST_TKVL.h" -#include "EST_Val.h" -#include "EST_types.h" -#include "EST_TIterator.h" -//#include "EST_error.h" - -class EST_TokenStream; -class EST_String; - -VAL_REGISTER_CLASS_DCLS(feats,EST_Features) - -// This shouldn't be here and only is for older code -typedef EST_Val (*EST_Item_featfunc)(class EST_Item *); -EST_Val est_val(const EST_Item_featfunc f); - - -/** A class for containing feature structures which can hold atomic -values (int, float, string) or other feature structures. -*/ - - -class EST_Features { - protected: - EST_TKVL *features; - - void save_fpair(ostream &outf, - const EST_String &fname, - const EST_Val &fvalue) const; - public: - static EST_Val feature_default_value; - EST_Features(); - EST_Features(const EST_Features &f); - ~EST_Features(); - - /**@name Access functions which return EST_Val. - Features can - either be simple features, in which their name is the name of - an plain attribute (e.g. "name"), or path features where their - name is a dot separated path of concatenated attributes - (e.g. "df.poa.alveolar"). - */ - //@{ - /** Look up directly without decomposing name as path (just simple feature) - */ - const EST_Val &val(const char *name) const; - - /** Look up directly without decomposing name as path (just simple feature), - returning def if not found - */ - const EST_Val &val(const char *name, const EST_Val &def) const; - - /** Look up feature name, which may be simple feature or path - */ - const EST_Val &val_path(const EST_String &path) const; - - /** Look up feature name, which may be simple feature or path, - returning def if not found - */ - const EST_Val &val_path(const EST_String &path, const EST_Val &def) const; - - /** Look up feature name, which may be simple feature or path. - */ - const EST_Val &operator() (const EST_String &path) const - {return val_path(path);} - - /** Look up feature name, which may be simple feature or path, - returning def if not found - */ - const EST_Val &operator() (const EST_String &path, const EST_Val &def) const - {return val_path(path, def);} - - /** Look up feature name, which may be simple feature or path. - */ - const EST_Val &f(const EST_String &path) const - { return val_path(path); } - - /** Look up feature name, which may be simple feature or path, - returning def if not found - */ - const EST_Val &f(const EST_String &path, const EST_Val &def) const - { return val_path(path,def); } - //@} - - /**@name Access functions which return types. - These functions cast - their EST_Val return value to a requested type, either float, - int, string or features (A). In all cases the name can be a - simple feature or a path, in which case their name is a dot - separated string of concatenated attributes - (e.g. "df.poa.alveolar"). */ - //@{ - - /** Look up feature name, which may be simple feature or path, and return - as a float */ - const float F(const EST_String &path) const - {return val_path(path).Float(); } - - /** Look up feature name, which may be simple feature or path, and - return as a float, returning def if not - found */ - const float F(const EST_String &path, float def) const - {return val_path(path, def).Float(); } - - /** Look up feature name, which may be simple feature or path, and return - as an int */ - const int I(const EST_String &path) const - {return val_path(path).Int(); } - - /** Look up feature name, which may be simple feature or path, and - return as an int, returning def if not - found */ - const int I(const EST_String &path, int def) const - {return val_path(path, def).Int(); } - - /** Look up feature name, which may be simple feature or path, and return - as a EST_String */ - const EST_String S(const EST_String &path) const - {return val_path(path).string(); } - - /** Look up feature name, which may be simple feature or path, and - return as a EST_String, returning def if not - found */ - - const EST_String S(const EST_String &path, const EST_String &def) const - {return val_path(path, def).string(); } - - /** Look up feature name, which may be simple feature or path, and return - as a EST_Features */ - EST_Features &A(const EST_String &path) const - {return *feats(val_path(path));} - - /** Look up feature name, which may be simple feature or path, and - return as a EST_Features, returning def if not - found */ - EST_Features &A(const EST_String &path, EST_Features &def) const; - - //@} - - /**@name Setting features - */ - //@{ - /** Add a new feature or set an existing feature name - to value ival - */ - void set(const EST_String &name, int ival) - { EST_Val pv(ival); set_path(name, pv);} - - /** Add a new feature or set an existing feature name - to value fval - */ - void set(const EST_String &name, float fval) - { EST_Val pv(fval); set_path(name, pv); } - - /** Add a new feature or set an existing feature name - to value dval - */ - void set(const EST_String &name, double dval) - { EST_Val pv((float)dval); set_path(name, pv); } - - /** Add a new feature or set an existing feature name - to value sval - */ - void set(const EST_String &name, const EST_String &sval) - { EST_Val pv(sval); set_path(name, pv); } - - /** Add a new feature or set an existing feature name - to value cval - */ - void set(const EST_String &name, const char *cval) - { EST_Val pv(cval); set_path(name, pv); } - - /** Add a new feature or set an existing feature name - to value val. Name must be - not be a path. - */ - void set_val(const EST_String &name, const EST_Val &sval) - { features->add_item(name,sval); } - - /** Add a new feature or set an existing feature name - to value val, where name - is a path. - */ - void set_path(const EST_String &name, const EST_Val &sval); - - /** Add a new feature feature or set an existing feature - name to value f, which - is the named of a registered feature function. - */ - void set_function(const EST_String &name, const EST_String &f); - - /** Add a new feature or set an existing feature - name to value f, - which itself is a EST_Features. The information in - f is copied into the features. */ - void set(const EST_String &name, EST_Features &f) - { EST_Features *ff = new EST_Features(f); - set_path(name, est_val(ff)); } - - //@} - - /**@name Utility functions - */ - - //@{ - /** remove the named feature */ - void remove(const EST_String &name) - { features->remove_item(name,1); } - - /** number of features in feature structure */ - int length() const { return features->length(); } - - /** return 1 if the feature is present */ - int present(const EST_String &name) const; - - /** Delete all features from object */ - void clear() { features->clear(); } - - /** Feature assignment */ - EST_Features& operator = (const EST_Features& a); - /** Print Features */ - friend ostream& operator << (ostream &s, const EST_Features &f) - { f.save(s); return s; } - //@} - - - // Iteration -#if 0 - EST_Litem *head() const { return features->list.head(); } - EST_String &fname(EST_Litem *p) const { return features->list(p).k; } - EST_Val &val(EST_Litem *p) const { return features->list(p).v; } - float F(EST_Litem *p) const { return features->list(p).v.Float(); } - EST_String S(EST_Litem *p) const { return features->list(p).v.string(); } - int I(EST_Litem *p) const { return features->list(p).v.Int(); } - EST_Features &A(EST_Litem *p) { return *feats(features->list(p).v); } -#endif - - - - protected: - struct IPointer { EST_TKVL::RwEntries i; }; - - void point_to_first(IPointer &ip) const - { ip.i.begin(*features);} - void move_pointer_forwards(IPointer &ip) const - { ++(ip.i); } - bool points_to_something(const IPointer &ip) const - { return ip.i != 0; } - EST_TKVI &points_at(const IPointer &ip) - { return *(ip.i); } - - friend class EST_TIterator< EST_Features, IPointer, EST_TKVI >; - friend class EST_TStructIterator< EST_Features, IPointer, EST_TKVI >; - friend class EST_TRwIterator< EST_Features, IPointer, EST_TKVI >; - friend class EST_TRwStructIterator< EST_Features, IPointer, EST_TKVI >; - -public: - - /**@name Iteration - */ - - //@{ - typedef EST_TKVI Entry; - typedef EST_TStructIterator< EST_Features, IPointer, Entry> Entries; - typedef EST_TRwStructIterator< EST_Features, IPointer, Entry> RwEntries; - //@} - - /**@name File I/O - */ - - //@{ - /// load features from already opened EST_TokenStream - EST_read_status load(EST_TokenStream &ts); - /// load features from sexpression, contained in already opened EST_TokenStream - EST_read_status load_sexpr(EST_TokenStream &ts); - /// save features in already opened ostream - EST_write_status save(ostream &outf) const; - /// save features as s-expression in already opened ostream - EST_write_status save_sexpr(ostream &outf) const; - - //@} -}; - -inline bool operator == (const EST_Features &a,const EST_Features &b) -{(void)a; (void)b; return false;} - -void merge_features(EST_Features &to,EST_Features &from); -EST_String error_name(const EST_Features &a); - -#endif - diff --git a/src/est/EST_Handleable.h b/src/est/EST_Handleable.h deleted file mode 100644 index 33b3cb5610..0000000000 --- a/src/est/EST_Handleable.h +++ /dev/null @@ -1,74 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - - -#ifndef __EST_HANDLABLE_H__ -#define __EST_HANDLABLE_H__ - -/** Reference Counting Interface. - * - * This simple class does most of the things an object which is to be - * manipulated by EST_THandle style smart pointers needs to provide. - * - * @see EST_THandle - * @see EST_TBox - * @see EST_TrackMap - * @author Richard Caley - * @version $Id: EST_Handleable.h,v 1.3 2004/05/04 00:00:16 awb Exp $ - */ - -#include - -class EST_Handleable -{ -private: - int p_refcount; - -public: -# define NOT_REFCOUNTED (INT_MAX) - - EST_Handleable(void) { p_refcount=NOT_REFCOUNTED; } - - int refcount(void) const { return p_refcount;} - - void start_refcounting(int initial=0) {p_refcount=initial;} - void inc_refcount(void) {if (p_refcount!=NOT_REFCOUNTED) p_refcount++;} - void dec_refcount(void) {if (p_refcount!=NOT_REFCOUNTED) p_refcount--;} - - int is_unreferenced(void) const {return p_refcount == 0;} - int is_refcounted(void) const {return p_refcount!= NOT_REFCOUNTED;} - //@} -}; - -#endif - diff --git a/src/est/EST_IMatrix.h b/src/est/EST_IMatrix.h deleted file mode 100644 index aa2122a4f5..0000000000 --- a/src/est/EST_IMatrix.h +++ /dev/null @@ -1,66 +0,0 @@ - /*************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - /* */ - /* Author : Paul Taylor */ - /* Date : April 1996 */ - /* --------------------------------------------------------------------- */ - /* Matrix class */ - /* */ - /*************************************************************************/ - -#ifndef __IMatrix_H__ -#define __IMatrix_H__ - -#include "EST_TSimpleMatrix.h" -#include "EST_TSimpleVector.h" - -/** A matrix class for integers. {\tt EST_IMatrix x} should be - used instead of {\tt int **x} wherever possible. -*/ -class EST_IMatrix: public EST_TSimpleMatrix { -private: -public: - /// size constructor - EST_IMatrix(int m, int n):EST_TSimpleMatrix(m, n) {} - /// copy constructor - EST_IMatrix(EST_IMatrix &a):EST_TSimpleMatrix(a) {} - /// CHECK - what does this do??? - EST_IMatrix(EST_IMatrix &a, int b); - /// default constructor - EST_IMatrix():EST_TSimpleMatrix() {} -}; - -/// find largest element -int matrix_max(const EST_IMatrix &a); - -#endif diff --git a/src/est/EST_Option.h b/src/est/EST_Option.h deleted file mode 100644 index 467725634f..0000000000 --- a/src/est/EST_Option.h +++ /dev/null @@ -1,105 +0,0 @@ -/*************************************************************************/ -/* */ -/* Centre for Speech Technology Research */ -/* University of Edinburgh, UK */ -/* Copyright (c) 1994,1995,1996 */ -/* All Rights Reserved. */ -/* */ -/* Permission is hereby granted, free of charge, to use and distribute */ -/* this software and its documentation without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of this work, and to */ -/* permit persons to whom this work is furnished to do so, subject to */ -/* the following conditions: */ -/* 1. The code must retain the above copyright notice, this list of */ -/* conditions and the following disclaimer. */ -/* 2. Any modifications must be clearly marked as such. */ -/* 3. Original authors' names are not deleted. */ -/* 4. The authors' names are not used to endorse or promote products */ -/* derived from this software without specific prior written */ -/* permission. */ -/* */ -/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ -/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ -/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ -/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ -/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ -/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ -/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ -/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ -/* THIS SOFTWARE. */ -/* */ -/*************************************************************************/ -/* Author : Paul Taylor */ -/* Date : September 1994 */ -/*-----------------------------------------------------------------------*/ -/* EST_Option Class header file */ -/* */ -/*=======================================================================*/ - -#ifndef __EST_OPTION_H__ -#define __EST_OPTION_H__ - -#include "EST_String.h" -#include "EST_TKVL.h" -#include "EST_rw_status.h" - -/** Provide a high level interface for String String key value lists. -*/ - -class EST_Option: public EST_TKVL { -public: - /// add prefix to every key - void add_prefix(EST_String prefix); - /// remove prefix from every key - void remove_prefix(EST_String prefix); - - /** read keyval list from file. The file type is an ascii file - with each line representing one key value pair. The first entry in - the line defines the key, and the rest, which may contain - whitespaces, defins the value. Lines starting with the comment - character are ignored. - @return returns EST_read_status errors, @see */ - EST_read_status load(const EST_String &filename, const EST_String &comment = ";"); - - /// add to end of list or overwrite. If rval is empty, do nothing - int override_val(const EST_String rkey, const EST_String rval); - /// add to end of list or overwrite. If rval is empty, do nothing - int override_fval(const EST_String rkey, const float rval); - /// add to end of list or overwrite. If rval is empty, do nothing - int override_ival(const EST_String rkey, const int rval); - - /** return value of type int relating to key. By default, - an error occurs if the key is not present. Use m=0 if - to get a dummy value returned if key is not present */ - int ival(const EST_String &rkey, int m=1) const; - - /** return value of type float relating to key. By default, - an error occurs if the key is not present. Use m=0 if - to get a dummy value returned if key is not present */ - double dval(const EST_String &rkey, int m=1) const; - - /** return value of type float relating to key. By default, - an error occurs if the key is not present. Use m=0 if - to get a dummy value returned if key is not present */ - float fval(const EST_String &rkey, int m=1) const; - - /** return value of type String relating to key. By default, - an error occurs if the key is not present. Use m=0 if - to get a dummy value returned if key is not present */ - const EST_String &sval(const EST_String &rkey, int m=1) const; - - /** return value of type String relating to key. By default, - an error occurs if the key is not present. Use m=0 if - to get a dummy value returned if key is not present */ -// const EST_String &val(const EST_String &rkey, int m=1) const -// { return sval(rkey,m); } - - int add_iitem(const EST_String &rkey, const int &rval); - int add_fitem(const EST_String &rkey, const float &rval); - - /// print options - friend ostream& operator << (ostream& s, const EST_Option &kv); -}; - -#endif // __EST_OPTION_H__ diff --git a/src/est/EST_Regex.h b/src/est/EST_Regex.h deleted file mode 100644 index 5101f32c49..0000000000 --- a/src/est/EST_Regex.h +++ /dev/null @@ -1,151 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1997 */ - /* All Rights Reserved. */ - /* */ -/* Permission is hereby granted, free of charge, to use and distribute */ -/* this software and its documentation without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of this work, and to */ -/* permit persons to whom this work is furnished to do so, subject to */ -/* the following conditions: */ -/* 1. The code must retain the above copyright notice, this list of */ -/* conditions and the following disclaimer. */ -/* 2. Any modifications must be clearly marked as such. */ -/* 3. Original authors' names are not deleted. */ -/* 4. The authors' names are not used to endorse or promote products */ -/* derived from this software without specific prior written */ -/* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /************************************************************************/ - -#ifndef __EST_REGEX_H__ -#define __EST_REGEX_H__ - -class EST_Regex; - -#include "EST_String.h" - -/** A Regular expression class to go with the CSTR EST_String class. - * - * The regular expression syntax is the FSF syntax used in emacs and - * in the FSF String library. This is translated into the syntax supported - * by Henry Spensor's regular expression library, this translation is a place - * to look if you find regular expressions not matching where expected. - * - * @see EST_String - * @see string_example - * @author Richard Caley - * @author (regular expression library by Henry Spencer, University of Toronto) - * @version $Id: EST_Regex.h,v 1.3 2004/05/04 00:00:16 awb Exp $ - */ - -class EST_Regex : protected EST_String { - -private: - /// The compiled form. - void *compiled; - /// Compiled form for whole string match. - void *compiled_match; - -protected: - /// Compile expression. - void compile(); - /// Compile expression in a form which only matches whole string. - void compile_match(); - /// Translate the expression into the internally used syntax. - char *regularize(int match) const; - -public: - /// Empty constructor, just for form. - EST_Regex(void); - - /// Construct from EST_String. - EST_Regex(EST_String s); - - /// Construct from C string. - EST_Regex(const char *ex); - - /// Copy constructor. - EST_Regex(const EST_Regex &ex); - - /// Destructor. - ~EST_Regex(); - - /// Size of the expression. - int size() const { return EST_String::size; }; - - /// Run to find a matching substring - int run(const char *on, int from, int &start, int &end, int *starts=NULL, int *ends=NULL); - /// Run to see if it matches the entire string. - int run_match(const char *on, int from=0, int *starts=NULL, int *ends=NULL); - - /// Get the expression as a string. - EST_String tostring(void) const {return (*this);}; - - /// Cast operator, disambiguates it for some compilers - operator const char *() const { return (const char *)tostring(); } - - int operator == (const EST_Regex ex) const - { return (const EST_String)*this == (const EST_String)ex; } - - int operator != (const EST_Regex ex) const - { return (const EST_String)*this != (const EST_String)ex; } - - /**@name Assignment */ - //@{ - /// - EST_Regex &operator = (const EST_Regex ex); - /// - EST_Regex &operator = (const EST_String s); - /// - EST_Regex &operator = (const char *s); - //@} - - /// Stream output of regular expression. - friend ostream &operator << (ostream &s, const EST_Regex &str); -}; - -ostream &operator << (ostream &s, const EST_Regex &str); - -/**@name Predefined_regular_expressions - * Some regular expressions matching common things are predefined - */ -//@{ -/// White space -extern EST_Regex RXwhite; // "[ \n\t\r]+" -/// Sequence of alphabetic characters. -extern EST_Regex RXalpha; // "[A-Za-z]+" -/// Sequence of lower case alphabetic characters. -extern EST_Regex RXlowercase; // "[a-z]+" -/// Sequence of upper case alphabetic characters. -extern EST_Regex RXuppercase; // "[A-Z]+" -/// Sequence of letters and/or digits. -extern EST_Regex RXalphanum; // "[0-9A-Za-z]+" -/// Initial letter or underscore followed by letters underscores or digits. -extern EST_Regex RXidentifier; // "[A-Za-z_][0-9A-Za-z_]+" -/// Integer. -extern EST_Regex RXint; // "-?[0-9]+" -/// Floating point number. -extern EST_Regex RXdouble; // "-?\\(\\([0-9]+\\.[0-9]*\\)\\|\\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)\\([eE][---+]?[0-9]+\\)?" -//@} - -// GCC lets us use the static constant to declare arrays, Sun CC -// doesn't, so for a quiet, if ugly, life we declare it here with a suitable -// value and check in EST_Regex.cc to make sure it`s OK - -#define EST_Regex_max_subexpressions 10 - -#endif diff --git a/src/est/EST_SMatrix.h b/src/est/EST_SMatrix.h deleted file mode 100644 index fa4fb17b54..0000000000 --- a/src/est/EST_SMatrix.h +++ /dev/null @@ -1,62 +0,0 @@ - /*************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - /* */ - /* Author : Paul Taylor */ - /* Date : April 1996 */ - /* --------------------------------------------------------------------- */ - /* Matrix class */ - /* */ - /*************************************************************************/ - -#ifndef __SMatrix_H__ -#define __SMatrix_H__ - -#include "EST_TSimpleMatrix.h" -#include "EST_TSimpleVector.h" - -class EST_SMatrix: public EST_TSimpleMatrix { -private: -public: - /// size constructor - EST_SMatrix(int m, int n):EST_TSimpleMatrix(m, n) {} - /// copy constructor - EST_SMatrix(EST_SMatrix &a):EST_TSimpleMatrix(a) {} - /// CHECK - what does this do??? - EST_SMatrix(EST_SMatrix &a, int b); - /// default constructor - EST_SMatrix():EST_TSimpleMatrix() {} - - int rateconv(int old_sr, int new_sr); -}; - -#endif diff --git a/src/est/EST_String.h b/src/est/EST_String.h deleted file mode 100644 index d9027420ab..0000000000 --- a/src/est/EST_String.h +++ /dev/null @@ -1,650 +0,0 @@ -/*************************************************************************/ -/* */ -/* Centre for Speech Technology Research */ -/* University of Edinburgh, UK */ -/* Copyright (c) 1997 */ -/* All Rights Reserved. */ -/* */ -/* Permission is hereby granted, free of charge, to use and distribute */ -/* this software and its documentation without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of this work, and to */ -/* permit persons to whom this work is furnished to do so, subject to */ -/* the following conditions: */ -/* 1. The code must retain the above copyright notice, this list of */ -/* conditions and the following disclaimer. */ -/* 2. Any modifications must be clearly marked as such. */ -/* 3. Original authors' names are not deleted. */ -/* 4. The authors' names are not used to endorse or promote products */ -/* derived from this software without specific prior written */ -/* permission. */ -/* */ -/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ -/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ -/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ -/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ -/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ -/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ -/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ -/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ -/* THIS SOFTWARE. */ -/* */ -/*************************************************************************/ - -#ifndef __EST_STRING_H__ -#define __EST_STRING_H__ - -#ifdef HAVE_CONFIG_H -# include "est_string_config.h" -#endif - -class EST_String; -class EST_Regex; - -#define EST_Regex_max_subexpressions 10 - -#include -#define NO_EST -#ifdef NO_EST -# include -#else -# include "EST_iostream.h" -#endif -#include -#include "EST_Chunk.h" -#include "EST_strcasecmp.h" -#include "EST_bool.h" - - -/** A non-copyleft implementation of a string class to use with - * compilers that aren't GNU C++. - * - * Strings are reference-counted and reasonably efficient (eg you - * can pass them around, into and out of functions and so on - * without worrying too much about the cost). - * - * The associated class EST_Regex can be used to represent regular - * expressions. - * - * @see EST_Chunk - * @see EST_Regex - * @see string_example - * @author Alan W Black - * @author Richard Caley - * @version $Id: EST_String.h,v 1.3 2004/05/04 00:00:16 awb Exp $ - */ - -class EST_String { - - /** For better libg++ compatibility. - * - * Includes String from char constructor which - * tends to mask errors in use. Also reverses the () and [] operators. - */ -# define __FSF_COMPATIBILITY__ (0) - - /** Allow gsub() to be used in multi-threaded applications - * This will cause gsub to use a local table of substitution points - * walloced for each gsub. Otherwise one global one is used which - * should be faster, but non reentrant. - */ -# define __GSUB_REENTRANT__ (1) - -/// Gripe about weird arguments like Nulls -#define __STRING_ARG_GRIPE__ (1) - -/// When we find something to gripe about we die then and there. -#define __GRIPE_FATAL__ (1) - -#if __GRIPE_FATAL__ -# define gripe(WHAT) (cerr<< ("oops! " WHAT "\n"),abort()) -#else -# define gripe(WHAT) (cerr<< ("oops! " WHAT "\n")) -#endif - -#if __STRING_ARG_GRIPE__ -# define safe_strlen(S) ((S)?strlen(S):(gripe("null strlen"),0)) -# define CHECK_STRING_ARG(S) if (!(S)) gripe("null string arg") -#else -# define safe_strlen(S) ((S)?strlen(S):0) -# define CHECK_STRING_ARG(S) /* empty */ -#endif - -public: - /// Global version string. - static const char *version; - - /// Constant empty string - static const EST_String Empty; - - /// Type of string size field. - typedef int EST_string_size; - /// Maximum string size. -# define MAX_STRING_SIZE (INT_MAX) - -private: - /// Smart pointer to actual memory. - EST_ChunkPtr memory; - /// Size of string. - EST_string_size size; - - // Make sure this is exactly the same as an EST_String. This is being too - // clever by half. - - struct EST_dumb_string { - EST_ChunkPtr memory; - EST_string_size size; - } ; - - /// Flags indicating which bit of a string to extract. - enum EST_chop_direction { - Chop_Before = -1, - Chop_At = 0, - Chop_After = 1 - }; - - /// Simple utility which removes const-ness from memory - static inline EST_ChunkPtr &NON_CONST_CHUNKPTR(const EST_ChunkPtr &ecp) - { return *((EST_ChunkPtr *)&ecp);} - - /// private constructor which uses the buffer given. - EST_String(int len, EST_ChunkPtr cp) { - size=len; - memory = cp; - } - - /// Is more than one String represented by the same memory? - int shareing (void) { return memory.shareing();} - - /**@name Finding substrings */ - //@{ - /// Find substring - int locate(const char *it, int len, int from, int &start, int &end) const; - /// Find substring - int locate(const EST_String &s, int from, int &start, int &end) const - { return locate((const char *)s.memory, s.size, from, start, end); } - /// Find match for regexp. - int locate(EST_Regex &ex, int from, int &start, int &end, int *starts=NULL, int *ends=NULL) const; - //@} - - - /**@name Extract Substrings */ - //@{ - int extract(const char *it, int len, int from, int &start, int &end) const; - int extract(const EST_String &s, int from, int &start, int &end) const - { return extract((const char *)s.memory, s.size, from, start, end); } - int extract(EST_Regex &ex, int from, int &start, int &end) const; - //@} - - /**@name Chop out part of string */ - //@{ - /// Locate subsring and chop. - EST_String chop_internal(const char *s, int length, int pos, EST_chop_direction directionult) const; - /// Chop at given position. - EST_String chop_internal(int pos, int length, EST_chop_direction directionult) const; - - /// Locate match for expression and chop. - EST_String chop_internal(EST_Regex &ex, int pos, EST_chop_direction directionult) const; - //@} - - /**@name Global search and replace */ - //@{ - /// Substitute for string - int gsub_internal(const char *os, int olength, const char *s, int length); - /// Substitute for matches of regexp. - int gsub_internal(EST_Regex &ex, const char *s, int length); - //@} - - /// Split the string down into parts. - int split_internal(EST_String result[], int max, const char* s_seperator, int slen, EST_Regex *re_separator, char quote) const; - - int Int(bool *ok_p) const; - long Long(bool *ok_p) const; - float Float(bool *ok_p) const; - double Double(bool *ok_p) const; -public: - - /// Construct an empty string. - EST_String(void) :memory() {size=0;} - - /// Construct from char * - EST_String(const char *s); - - /// Construct from part of char * or fill with given character. - EST_String(const char *s, int start_or_fill, int len); - - /// Construct from C string. - EST_String(const char *s, int s_size, int start, int len); - - // Create from EST_String - EST_String(const EST_String &s, int start, int len); - - /** Copy constructor - * We have to declare our own copy constructor to lie to the - * compiler about the constness of the RHS. - */ - EST_String(const EST_String &s) { - memory = NON_CONST_CHUNKPTR(s.memory); - size = s.size; - } - -#if __FSF_COMPATIBILITY__ - /** Construct from single char. - * This constructor is not usually included as it can mask errors. - * @see __FSF_COMPATIBILITY__ - */ - EST_String(const char c); -#endif - - /// Destructor. - ~EST_String() { - size=0; - memory=NULL; - } - - /// Length of string ({\em not} length of underlying chunk) - int length(void) const { return size; } - /// Size of underlying chunk. - int space (void) const { return memory.size(); } - /// Get a const-pointer to the actual memory. - const char *str(void) const { return size==0?"":(const char *)memory; } - /// Get a writable pointer to the actual memory. - char *updatable_str(void) { return size==0?(char *)"":(char *)memory; } - void make_updatable(void) { ::make_updatable(memory, size+1);} - - - /// Build string from a single character. - static EST_String FromChar(const char c) - { const char s[2] = { c, 0 }; return EST_String(s); } - - /// Build string from an integer. - static EST_String Number(int i, int base=10); - - /// Build string from a long integer. - static EST_String Number(long i, int base=10); - - /// Build string from a double. - static EST_String Number(double d); - - /// Build string from a float - static EST_String Number(float f); - - /// Convert to an integer - int Int(bool &ok) const { return Int(&ok); } - int Int(void) const { return Int((bool *)NULL); } - - /// Convert to a long - long Long(bool &ok) const { return Long(&ok); } - long Long(void) const { return Long((bool *)NULL); } - - /// Convert to a float - float Float(bool &ok) const { return Float(&ok); } - float Float(void) const { return Float((bool *)NULL); } - - /// Convert to a double - double Double(bool &ok) const { return Double(&ok); } - double Double(void) const { return Double((bool *)NULL); } - - /**@name Before */ - //@{ - /// Part before position - EST_String before(int pos, int len=0) const - { return chop_internal(pos, len, Chop_Before); } - /// Part before first matching substring after pos. - EST_String before(const char *s, int pos=0) const - { return chop_internal(s, safe_strlen(s), pos, Chop_Before); } - /// Part before first matching substring after pos. - EST_String before(const EST_String &s, int pos=0) const - { return chop_internal(s.str(), s.size, pos, Chop_Before); } - /// Part before first match of regexp after pos. - EST_String before(EST_Regex &e, int pos=0) const - { return chop_internal(e, pos, Chop_Before); } - //@} - - /**@name At */ - //@{ - /// Return part at position - EST_String at(int from, int len=0) const - { return EST_String(str(),size,from<0?(size+from):from,len); } - /// Return part where substring found (not useful, included for completeness) - EST_String at(const char *s, int pos=0) const - { return chop_internal(s, safe_strlen(s), pos, Chop_At); } - /// Return part where substring found (not useful, included for completeness) - EST_String at(const EST_String &s, int pos=0) const - { return chop_internal(s.str(), s.size, pos, Chop_At); } - /// Return part matching regexp. - EST_String at(EST_Regex &e, int pos=0) const - { return chop_internal(e, pos, Chop_At); } - //@} - - /**@name After */ - //@{ - /// Part after pos+len - EST_String after(int pos, int len=1) const - { return chop_internal(pos, len, Chop_After); } - /// Part after substring. - EST_String after(const char *s, int pos=0) const - { return chop_internal(s, safe_strlen(s), pos, Chop_After); } - /// Part after substring. - EST_String after(const EST_String &s, int pos=0) const - { return chop_internal(s.str(), s.size, pos, Chop_After); } - /// Part after match of regular expression. - EST_String after(EST_Regex &e, int pos=0) const - { return chop_internal(e, pos, Chop_After); } - //@} - - /**@name Search for something */ - //@{ - /// Find a substring. - int search(const char *s, int len, int &mlen, int pos=0) const - { int start, end; - if (locate(s, len, pos, start, end)) - { mlen=end-start; return start; } - return -1; - } - - /// Find a substring. - int search(const EST_String s, int &mlen, int pos=0) const - { int start, end; - if (locate(s, pos, start, end)) - { mlen=end-start; return start; } - return -1; - } - - /// Find a match of the regular expression. - int search(EST_Regex &re, int &mlen, int pos=0, int *starts=NULL, int *ends=NULL) const - { int start, end; - if (locate(re, pos, start, end, starts, ends)) - { mlen=end-start; return start; } - return -1; - } - //@} - - - /**@name Get position of something */ - //@{ - /// Position of substring (starting at pos) - int index(const char *s, int pos=0) const - { int start, end; return locate(s, safe_strlen(s), pos, start, end)?start:-1; } - /// Position of substring (starting at pos) - int index(const EST_String &s, int pos=0) const - { int start, end; return locate(s, pos, start, end)?start:-1; } - /// Position of match of regexp (starting at pos) - int index(EST_Regex &ex, int pos=0) const - { int start, end; return locate(ex, pos, start, end)?start:-1; } - //@} - - /**@name Does string contain something? */ - //@{ - /// Does it contain this substring? - int contains(const char *s, int pos=-1) const - { int start, end; return extract(s, safe_strlen(s), pos, start, end); } - /// Does it contain this substring? - int contains(const EST_String &s, int pos=-1) const - { int start, end; return extract(s, pos, start, end); } - /// Does it contain this character? - int contains(const char c, int pos=-1) const - { int start, end; char s[2] = {c,0}; return extract(s, 1, pos, start, end); } - /// Does it contain a match for this regular expression? - int contains(EST_Regex &ex, int pos=-1) const - { int start, end; return extract(ex, pos, start, end); } - //@} - - /**@name Does string exactly match? */ - //@{ - /// Exactly match this string? - int matches(const char *e, int pos=0) const; - /// Exactly match this string? - int matches(const EST_String &e, int pos=0) const; - /// Exactly matches this regular expression, can return ends of sub-expressions. - int matches(EST_Regex &e, int pos=0, int *starts=NULL, int *ends=NULL) const; - //@} - - /**@name Global replacement */ - //@{ - /// Substitute one string for another. - int gsub(const char *os, const EST_String &s) - { return gsub_internal(os, safe_strlen(os), s, s.size); } - /// Substitute one string for another. - int gsub(const char *os, const char *s) - { return gsub_internal(os, safe_strlen(os), s, safe_strlen(s)); } - /// Substitute one string for another. - int gsub(const EST_String &os, const EST_String &s) - { return gsub_internal(os, os.size, s, s.size); } - /// Substitute one string for another. - int gsub(const EST_String &os, const char *s) - { return gsub_internal(os, os.size, s, safe_strlen(s)); } - - /// Substitute string for matches of regular expression. - int gsub(EST_Regex &ex, const EST_String &s) - { return gsub_internal(ex, s, s.size); } - /// Substitute string for matches of regular expression. - int gsub(EST_Regex &ex, const char *s) - { return gsub_internal(ex, s, safe_strlen(s)); } - /// Substitute string for matches of regular expression. - int gsub(EST_Regex &ex, int bracket_num) - { return gsub_internal(ex, NULL, bracket_num); } - /// Substitute the result of a match into a string. - int subst(EST_String source, - int (&starts)[EST_Regex_max_subexpressions], - int (&ends)[EST_Regex_max_subexpressions]); - //@} - - /**@name Frequency counts */ - //@{ - /// Number of occurrences of substring - int freq(const char *s) const; - /// Number of occurrences of substring - int freq(const EST_String &s) const; - /// Number of matches of regular expression. - int freq(EST_Regex &s) const; - //@} - - /**@name Quoting */ - //@{ - /// Return the string in quotes with internal quotes protected. - EST_String quote(const char quotec) const; - /// Return in quotes if there is something to protect (e.g. spaces) - EST_String quote_if_needed(const char quotec) const; - /// Remove quotes and unprotect internal quotes. - EST_String unquote(const char quotec) const; - /// Remove quotes if any. - EST_String unquote_if_needed(const char quotec) const; - //@} - -#if __FSF_COMPATIBILITY__ - const char operator [] (int i) const { return memory[i]; } - char &operator () (int i) { return memory(i); } -#else - /**@name Operators */ - //@{ - /// Function style access to constant strings. - const char operator () (int i) const { return memory[i]; } - /// Array style access to writable strings. - char &operator [] (int i) { return memory(i); } -#endif - - /// Cast to const char * by simply giving access to pointer. - operator const char*() const {return str(); } - operator const char*() {return str(); } - /// Cast to char *, may involve copying. - operator char*() { return updatable_str(); } - - /**@name Add to end of string. */ - //@{ - /// Add C string to end of EST_String - EST_String &operator += (const char *b); - /// Add EST_String to end of EST_String - EST_String &operator += (const EST_String b); - //@} - - /**@name Assignment */ - //@{ - /// Assign C string to EST_String - EST_String &operator = (const char *str); - /// Assign single character to EST_String - EST_String &operator = (const char c); - /// Assign EST_String to EST_String. - EST_String &operator = (const EST_String &s); - //@} - - /**@name Concatenation */ - //@{ - /// Concatenate two EST_Strings - friend EST_String operator + (const EST_String &a, const EST_String &b); - /// Concatenate C String with EST_String - friend EST_String operator + (const char *a, const EST_String &b); - /// Concatenate EST_String with C String - friend EST_String operator + (const EST_String &a, const char *b); - //@} - - /// Repeat string N times - friend EST_String operator * (const EST_String &s, int n); - - /**@name relational operators */ - //@{ - /// - friend int operator == (const char *a, const EST_String &b); - /// - friend int operator == (const EST_String &a, const char *b) - { return b == a; } - /// - friend int operator == (const EST_String &a, const EST_String &b); - - /// - friend int operator != (const char *a, const EST_String &b) - { return !(a==b); } - /// - friend int operator != (const EST_String &a, const char *b) - { return !(a==b); } - /// - friend int operator != (const EST_String &a, const EST_String &b) - { return !(a==b); } - - /// - friend inline int operator < (const char *a, const EST_String &b) - { return compare(a,b) < 0; } - /// - friend inline int operator < (const EST_String &a, const char *b) - { return compare(a,b) < 0; } - /// - friend inline int operator < (const EST_String &a, const EST_String &b) - { return compare(a,b) < 0; } - /// - friend inline int operator > (const char *a, const EST_String &b) - { return compare(a,b) > 0; } - /// - friend inline int operator > (const EST_String &a, const char *b) - { return compare(a,b) > 0; } - /// - friend inline int operator > (const EST_String &a, const EST_String &b) - { return compare(a,b) > 0; } - /// - friend inline int operator <= (const char *a, const EST_String &b) - { return compare(a,b) <= 0; } - /// - friend inline int operator <= (const EST_String &a, const char *b) - { return compare(a,b) <= 0; } - /// - friend inline int operator <= (const EST_String &a, const EST_String &b) - { return compare(a,b) <= 0; } - /// - friend inline int operator >= (const char *a, const EST_String &b) - { return compare(a,b) >= 0; } - /// - friend inline int operator >= (const EST_String &a, const char *b) - { return compare(a,b) >= 0; } - /// - friend inline int operator >= (const EST_String &a, const EST_String &b) - { return compare(a,b) >= 0; } - //@} - - //@} - - /**@name String comparison. - * All these operators return -1, 0 or 1 to indicate the sort - * order of the strings. - */ - //@{ - /// - friend int compare(const EST_String &a, const EST_String &b); - /// - friend int compare(const EST_String &a, const char *b); - /// - friend inline int compare(const char *a, const EST_String &b) - { return -compare(b,a); } - /** Case folded comparison. - * - * The table argument can defined how upper and lower - * case characters correspond. The default works for - * ASCII. - */ - //@{ - friend int fcompare(const EST_String &a, const EST_String &b, - const unsigned char *table=NULL); - - friend int fcompare(const EST_String &a, const char *b, - const unsigned char *table=NULL); - /// - friend inline int fcompare(const EST_String &a, const EST_String &b, - const EST_String &table) - { return fcompare(a, b, (const unsigned char *)(const char *)table); } - //@} - //@} - //@} - - - /**@name Split a string into parts. - * - * These functions divide up a string producing an array of - * substrings. - */ - //@{ - /// Split at a given separator. - friend int split(const EST_String & s, EST_String result[], - int max, const EST_String& seperator, char quote=0) - { return s.split_internal(result, max, (const char *)seperator, seperator.length(), NULL, quote); } - /// Split at a given separator. - friend int split(const EST_String &s, EST_String result[], - int max, const char *seperator, char quote=0) - { return s.split_internal(result, max, seperator, strlen(seperator), NULL, quote); } - /// Split at each match of the regular expression. - friend int split(const EST_String & s, EST_String result[], int max, - EST_Regex& seperator, char quote=0) - { return s.split_internal(result, max, NULL, 0, &seperator, quote); } - //@} - - /// Convert to upper case. - friend EST_String upcase(const EST_String &s); - /// Convert to lower case. - friend EST_String downcase(const EST_String &s); - - /** Concatenate a number of strings. - * This is more efficient than multiple uses of + or += - */ - static EST_String cat(const EST_String s1, - const EST_String s2 = Empty, - const EST_String s3 = Empty, - const EST_String s4 = Empty, - const EST_String s5 = Empty, - const EST_String s6 = Empty, - const EST_String s7 = Empty, - const EST_String s8 = Empty, - const EST_String s9 = Empty - ); - - /* Hacky way to ignore volatile */ - EST_String & ignore_volatile(void) volatile { return *((EST_String *)(void *)this); } - - /// Stream output for EST_String. - friend ostream &operator << (ostream &s, const EST_String &str); - friend class EST_Regex; -}; - -int operator == (const char *a, const EST_String &b); -int operator == (const EST_String &a, const EST_String &b); -ostream &operator << (ostream &s, const EST_String &str); - -#include "EST_Regex.h" - -#endif diff --git a/src/est/EST_THandle.h b/src/est/EST_THandle.h deleted file mode 100644 index 7cf663d8f2..0000000000 --- a/src/est/EST_THandle.h +++ /dev/null @@ -1,155 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - -#ifndef __EST_THANDLE_H__ -#define __EST_THANDLE_H__ - -#include "EST_iostream.h" -#include "EST_bool.h" - -/** A `smart' pointer which does reference counting. - * - * Behaves almost like a pointer as far as naive code is concerned, but - * keeps count of how many handles are holding on to the contents - * and deletes it when there are none. - * - * You need to be careful there are no dumb C++ pointers to things which - * are being handled this way. - * - * Things to be handled should implement the same interface as EST_Handleable - * (either by taking that as a superclass or by reimplementing it) and in - * addition define {\tt object_ptr()}. See EST_TBox for an example. - * - * There are two parameter types. In most cases the thing which contains the - * reference count and the data it represents will be the same object, but - * in the case of boxed values it may not be, so you can specify the type - * of both independently. - * - * @see EST_Handleable - * @see EST_TBox - * @see EST_THandle:example - * - * @author Richard Caley - * @version $Id: EST_THandle.h,v 1.3 2004/05/04 00:00:16 awb Exp $ - */ - - -template -class EST_THandle { - -private: - BoxT *ptr; - -public: - - EST_THandle(void) { ptr = (BoxT *)NULL; } - - EST_THandle(BoxT *p) { if ((ptr=p)) p->inc_refcount(); } - - EST_THandle(const EST_THandle &cp) { - ptr=cp.ptr; - if (ptr) - ptr->inc_refcount(); - } - - ~EST_THandle(void) { - if (ptr) - ptr->dec_refcount(); - if (ptr && ptr->is_unreferenced()) - delete ptr; - } - - bool null() const { return ptr == NULL; } - - int shareing(void) const { return ptr?(ptr->refcount() > 1):0; } - - EST_THandle &operator = (EST_THandle h) { - // doing it in this order means self assignment is safe. - if (h.ptr) - (h.ptr)->inc_refcount(); - if (ptr) - ptr->dec_refcount(); - if (ptr && ptr->is_unreferenced()) - delete ptr; - ptr=h.ptr; - return *this; - } - - // If they manage to get hold of one... - // Actually usually used to assign NULL and so (possibly) deallocate - // the object currently pointed to. - EST_THandle &operator = (BoxT *t_ptr) { - // doing it in this order means self assignment is safe. - if (t_ptr) - t_ptr->inc_refcount(); - if (ptr) - ptr->dec_refcount(); - if (ptr && ptr->is_unreferenced()) - delete ptr; - ptr=t_ptr; - return *this; - } - - operator ObjectT *() { - return ptr?(ptr->object_ptr()):(ObjectT *)NULL; - } - - operator const ObjectT *() const { - return ptr?(ptr->object_ptr()):(const ObjectT *)NULL; - } - - - int operator == (const BoxT *p) const { return ptr == p; } - int operator != (const BoxT *p) const { return !(*this == p); } - - const ObjectT& operator *() const { return *(ptr->object_ptr()); } - ObjectT& operator *() { return *(ptr->object_ptr()); } - const ObjectT* operator ->() const { return (ptr->object_ptr()); } - ObjectT* operator ->() { return (ptr->object_ptr()); } - - friend int operator == (const EST_THandle< BoxT, ObjectT > &a, const EST_THandle< BoxT, ObjectT > & b); - friend int operator != (const EST_THandle< BoxT, ObjectT > &a, const EST_THandle< BoxT, ObjectT > & b); - - friend ostream & operator << (ostream &s, const EST_THandle< BoxT, ObjectT > &a); -}; - -template -int operator == (const EST_THandle< BoxT, ObjectT > &a, const EST_THandle< BoxT, ObjectT > & b) { return a.ptr==b.ptr; } - -template -int operator != (const EST_THandle< BoxT, ObjectT > &a, const EST_THandle< BoxT, ObjectT > & b) { return !( a==b ); } - -template -ostream & operator << (ostream &s, const EST_THandle< BoxT, ObjectT > &a) { return s << "HANDLE"; } - -#endif diff --git a/src/est/EST_TIterator.h b/src/est/EST_TIterator.h deleted file mode 100644 index dadcb99882..0000000000 --- a/src/est/EST_TIterator.h +++ /dev/null @@ -1,298 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /************************************************************************/ - -#ifndef __EST_TITERATOR_H__ -#define __EST_TITERATOR_H__ - -/** Template class defining interface to an iterator, i.e an object - * which returns elements from a structure one at a time. - * - * This is template is usually hidden in the declaration of the - * container classes with a typedef for Entries providing a more - * convenient name for the iterator. However the interface is that - * defined here. - * - * We support two interfaces, a pointer like interface similar to - * specialised iteration code elsewhere in the speech tools library - * and to the iterators in the C++ standard template library and an - * interface similar to that of Enumerations in Java. - * - * - * MyContainer::Entries them; - * - * for(them.begin(container); them; them++) - * { - * MyContainer::Entry &it = *them; - * // Do Something With it - * } - * - * - * MyContainer::Entries them; - * - * them.begin(container); - * while (them.has_more_entries()) - * { - * MyContainer::Entry &it = them.next_entry(); - * // Do Something With it - * } - * - * @author Richard Caley - * @version $Id: EST_TIterator.h,v 1.6 2004/05/04 00:00:16 awb Exp $ - */ - -template - class EST_TStructIterator; -template - class EST_TRwIterator; -template - class EST_TRwStructIterator; - -template -class EST_TIterator -{ -protected: - /// The container we are looking at. - Container *cont; - - /// Position in the structure. May or may not be useful. - unsigned int pos; - - /** Structure defined by the container class which contains the - * current state of the iteration. - */ - IPointer pointer; - -public: - /// Name for an iterator like this - typedef EST_TIterator Iter; - - /// Create an iterator not associated with any specific container. - EST_TIterator() {cont=NULL;} - - /// Create an iterator ready to run over the given container. - EST_TIterator(const Container &over) - { begin(over); } - - /// Copy an iterator by assignment - Iter &operator = (const Iter &orig) - { cont=orig.cont; pos=orig.pos; pointer=orig.pointer; return *this;} - - /// Assigning a container to an iterator sets it ready to start. - Iter &operator = (const Container &over) - { begin(over); return *this;} - - /// Set the iterator ready to run over this container. - void begin(const Container &over) - {cont=((Container *)(void *)&over); beginning();} - - /// Reset to the start of the container. - void beginning() - {if (cont) cont->point_to_first(pointer); pos=0;} - - /**@name End Tests - */ - //@{ - /// True if there are more elements to look at. - bool has_more_elements() const - {return cont && cont->points_to_something(pointer);} - - /// True when there are no more. - bool at_end() const - {return !has_more_elements();} - - /** Viewing the iterator as an integer (for instance in a test) - * sees a non-zero value iff there are elements still to look at. - */ - operator int() const - {return has_more_elements();} - //@} - - /**@name Moving Forward - */ - //@{ - /// Next moves to the next entry. - void next() - {cont->move_pointer_forwards(pointer); pos++;} - - /// The increment operator does the same as next. - Iter &operator ++() - {next(); return *this;} - Iter operator ++(int dummy) - { - (void)dummy; - Iter old =*this; - next(); - return old; - } - //@} - - /**@name Access - */ - //@{ - /// Return the element currently pointed to. - const Entry& current() const - {return cont->points_at(pointer);} - - /// The * operator returns the current element. - const Entry &operator *() const - {return current();} - -#if 0 - // This only works for some Entry types. - const Entry *operator ->() const - {return ¤t();} -#endif - - /// Return the current element and move the pointer forwards. - const Entry& next_element() - { - const Entry &it = cont->points_at(pointer); - cont->move_pointer_forwards(pointer); - return it; - } - - /// Return the current position - - unsigned int n() const { return pos; } - //@} - - friend class EST_TStructIterator ; - friend class EST_TRwIterator ; - friend class EST_TRwStructIterator ; - -}; - -template -class EST_TStructIterator - : public EST_TIterator -{ -public: - - typedef EST_TIterator Iter; - - /// Create an iterator not associated with any specific container. - EST_TStructIterator() {this->cont=NULL;} - - /// Copy an iterator by assignment - Iter &operator = (const Iter &orig) - { this->cont=orig.cont; this->pos=orig.pos; this->pointer=orig.pointer; return *this;} - - /// Create an iterator ready to run over the given container. - EST_TStructIterator(const Container &over) - { begin(over); } - - const Entry *operator ->() const - {return &this->current();} -}; - -template -class EST_TRwIterator - : public EST_TIterator -{ -private: - /// Can't access constant containers this way. - // EST_TRwIterator(const Container &over) { (void) over; } - - /// Can't access constant containers this way. - // void begin(const Container &over) { (void) over; } - -public: - - typedef EST_TIterator Iter; - - /// Create an iterator not associated with any specific container. - EST_TRwIterator() {this->cont=NULL;} - - /// Copy an iterator by assignment - Iter &operator = (const Iter &orig) - { this->cont=orig.cont; this->pos=orig.pos; this->pointer=orig.pointer; return *this;} - - /// Create an iterator ready to run over the given container. - EST_TRwIterator(Container &over) - { begin(over); } - - /// Set the iterator ready to run over this container. - void begin(Container &over) - {this->cont=&over; this->beginning();} - - /**@name Access - */ - //@{ - /// Return the element currently pointed to. - Entry& current() const - {return this->cont->points_at(this->pointer);} - - /// The * operator returns the current element. - Entry &operator *() const - {return current();} - -#if 0 - Entry *operator ->() const - {return ¤t();} -#endif - - /// Return the current element and move the pointer forwards. - Entry& next_element() - { - Entry &it = this->cont->points_at(this->pointer); - this->cont->move_pointer_forwards(this->pointer); - return it; - } - - //@} -}; - -template -class EST_TRwStructIterator - : public EST_TRwIterator -{ -public: - - typedef EST_TIterator Iter; - - /// Create an iterator not associated with any specific container. - EST_TRwStructIterator() {this->cont=NULL;} - - /// Copy an iterator by assignment - Iter &operator = (const Iter &orig) - { this->cont=orig.cont; this->pos=orig.pos; this->pointer=orig.pointer; return *this;} - - /// Create an iterator ready to run over the given container. - EST_TRwStructIterator(Container &over) - { begin(over); } - - Entry *operator ->() const - {return &this->current();} -}; - -#endif diff --git a/src/est/EST_TIteratorI.h b/src/est/EST_TIteratorI.h deleted file mode 100644 index 5d8bd0c9c4..0000000000 --- a/src/est/EST_TIteratorI.h +++ /dev/null @@ -1,59 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - - -#ifndef __EST_TITERATORI_H__ -#define __EST_TITERATORI_H__ - -/** Instantiate an iterator. - * - * @author Richard Caley - * @version $Id: EST_TIteratorI.h,v 1.2 2001/04/04 13:11:27 awb Exp $ - */ - -#define Instantiate_TIterator_T(CONTAINER, IP, ENTRY, TAG) \ - template class EST_TIterator; \ - template class EST_TRwIterator; - -#define Declare_TIterator_T(CONTAINER, IP, ENTRY, TAG)\ - /* EMPTY */ - -#define Instantiate_TStructIterator_T(CONTAINER, IP, ENTRY, TAG) \ - template class EST_TStructIterator; \ - template class EST_TRwStructIterator; - -#define Declare_TIterator_T(CONTAINER, IP, ENTRY, TAG)\ - /* EMPTY */ - -#endif - diff --git a/src/est/EST_TKVL.h b/src/est/EST_TKVL.h deleted file mode 100644 index fbedaf3087..0000000000 --- a/src/est/EST_TKVL.h +++ /dev/null @@ -1,201 +0,0 @@ -/*************************************************************************/ -/* */ -/* Centre for Speech Technology Research */ -/* University of Edinburgh, UK */ -/* Copyright (c) 1995,1996 */ -/* All Rights Reserved. */ -/* */ -/* Permission is hereby granted, free of charge, to use and distribute */ -/* this software and its documentation without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of this work, and to */ -/* permit persons to whom this work is furnished to do so, subject to */ -/* the following conditions: */ -/* 1. The code must retain the above copyright notice, this list of */ -/* conditions and the following disclaimer. */ -/* 2. Any modifications must be clearly marked as such. */ -/* 3. Original authors' names are not deleted. */ -/* 4. The authors' names are not used to endorse or promote products */ -/* derived from this software without specific prior written */ -/* permission. */ -/* */ -/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ -/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ -/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ -/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ -/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ -/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ -/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ -/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ -/* THIS SOFTWARE. */ -/* */ -/*************************************************************************/ -/* Author : Paul Taylor */ -/* Date : January 1995 */ -/*-----------------------------------------------------------------------*/ -/* Key/Value list template class */ -/* */ -/*=======================================================================*/ -#ifndef __EST_TKVL_H__ -#define __EST_TKVL_H__ - -#include -#include "EST_TList.h" -#include "EST_TKVLI.h" -#include "EST_TIterator.h" - -class EST_String; - - -/** Templated Key-Value Item. Serves as the items in the list of the -EST_TKVL class. */ -template class EST_TKVI { - public: - K k; - V v; - - inline bool operator==(const EST_TKVI &i){ - return( (i.k == k) && (i.v == v) ); - } - - friend ostream& operator << (ostream& s, EST_TKVI const &i); -}; - - -/** Templated Key-Value list. Objects of type EST_TKVL contain lists which -are accessed by a key of type {\bf K}, which returns a value of type -{\bf V}. */ -template class EST_TKVL { - private: - EST_Litem *find_pair_key(const K &key) const; - EST_Litem *find_pair_val(const V &val) const; - public: - /**@name Constructor functions */ - //@{ - /// default constructor - EST_TKVL() {;} - /// copy constructor - EST_TKVL(const EST_TKVL &kv); - //@} - - /// default value, returned when there is no such entry. - static V *default_val; - - /// default value, returned when there is no such entry. - static K *default_key; - - /// Linked list of key-val pairs. Don't use - /// this as it will be made private in the future - EST_TList< EST_TKVI > list; - - /// number of key value pairs in list - const int length() const {return list.length();} - - /// Return First key value pair in list - EST_Litem * head() const {return list.head();}; - - /// Empty list. - void clear(); - - /**@name Access functions. - */ - //@{ - /// return value according to key (const) - const V &val(const K &rkey, bool m=0) const; - /// return value according to key (non-const) - V &val(const K &rkey, bool m=0); - /// return value according to ptr - const V &val(EST_Litem *ptr, bool m=0) const; - /// return value according to ptr - V &val(EST_Litem *ptr, bool m=0); - /// value or default - const V &val_def(const K &rkey, const V &def) const; - - /// find key, reference by ptr - const K &key(EST_Litem *ptr, int m=1) const; - /// find key, reference by ptr - K &key(EST_Litem *ptr, int m=1); - - /// return first matching key, referenced by val - const K &key(const V &v, int m=1) const; - - /** change key-val pair. If no corresponding entry is present, add - to end of list. - */ - int change_val(const K &rkey,const V &rval); - /** change key-val pair. If no corresponding entry is present, add - to end of list.*/ - int change_val(EST_Litem *ptr,const V &rval); // change key-val pair. - /// change name of key pair. - int change_key(EST_Litem *ptr,const K &rkey); - - /// add key-val pair to list - int add_item(const K &rkey,const V &rval, int no_search = 0); - - /// remove key and val pair from list - int remove_item(const K &rkey, int quiet = 0); - - //@} - - /// Returns true if key is present. - const int present(const K &rkey) const; - - /// apply function to each pair - void map(void (*func)(K&, V&)); - - friend ostream& operator << (ostream& s, EST_TKVL const &kv); - - /// full copy of KV list. - EST_TKVL & operator = (const EST_TKVL &kv); - /// add kv after existing list. - EST_TKVL & operator += (const EST_TKVL &kv); - /// make new concatenated list - EST_TKVL operator + (const EST_TKVL &kv); - - // Iteration support - -protected: - struct IPointer { EST_Litem *p; }; - - void point_to_first(IPointer &ip) const { ip.p = list.head(); } - void move_pointer_forwards(IPointer &ip) const { ip.p = next(ip.p); } - bool points_to_something(const IPointer &ip) const { return ip.p != NULL; } - EST_TKVI &points_at(const IPointer &ip) { return list(ip.p); } - - friend class EST_TIterator< EST_TKVL, IPointer, EST_TKVI >; - friend class EST_TStructIterator< EST_TKVL, IPointer, EST_TKVI >; - friend class EST_TRwIterator< EST_TKVL, IPointer, EST_TKVI >; - friend class EST_TRwStructIterator< EST_TKVL, IPointer, EST_TKVI >; - -public: - typedef EST_TKVI Entry; - typedef EST_TStructIterator< EST_TKVL, IPointer, Entry> Entries; - typedef EST_TRwStructIterator< EST_TKVL, IPointer, Entry> RwEntries; - - // Iteration support - -protected: - struct IPointer_k { EST_Litem *p; }; - - void point_to_first(IPointer_k &ip) const { ip.p = list.head(); } - void move_pointer_forwards(IPointer_k &ip) const { ip.p = next(ip.p); } - bool points_to_something(const IPointer_k &ip) const { return ip.p != NULL; } - K &points_at(const IPointer_k &ip) { return list(ip.p).k; } - - friend class EST_TIterator< EST_TKVL, IPointer_k, K >; - friend class EST_TRwIterator< EST_TKVL, IPointer_k, K >; - -public: - typedef K KeyEntry; - typedef EST_TIterator< EST_TKVL, IPointer_k, KeyEntry> KeyEntries; - typedef EST_TRwIterator< EST_TKVL, IPointer_k, KeyEntry> KeyRwEntries; - -}; - -template -extern ostream& operator << (ostream& s, EST_TKVI const &i); - -template -extern ostream& operator << (ostream& s, EST_TKVL const &l); - -#endif // __KVL_H__ diff --git a/src/est/EST_TKVLI.h b/src/est/EST_TKVLI.h deleted file mode 100644 index b1d5fe5c08..0000000000 --- a/src/est/EST_TKVLI.h +++ /dev/null @@ -1,125 +0,0 @@ - - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - - -#ifndef __EST_KVL_I_H__ -#define __EST_KVL_I_H__ - -/** Instantiate rules for list template. - * - * @author Richard Caley - * @version $Id: EST_TKVLI.h,v 1.3 2004/05/04 00:00:17 awb Exp $ - */ - -#include "EST_TListI.h" -#include "EST_TIteratorI.h" - -// Instantiation Macros - -// the typedef is purely to get the type name through the following macro. - -#define Instantiate_KVL_T(KEY, VAL, TAG) \ - template class EST_TKVL; \ - template class EST_TKVI; \ - ostream &operator<<(ostream &s, EST_TKVI< KEY , VAL > const &i){ return s << i.k << "\t" << i.v << "\n"; } \ - ostream& operator << (ostream& s, EST_TKVL< KEY , VAL > const &l) {EST_Litem *p; for (p = l.list.head(); p ; p = next(p)) s << l.list(p).k << "\t" << l.list(p).v << endl; return s;} \ - Instantiate_TIterator_T(KVL_ ## TAG ## _t, KVL_ ## TAG ## _t::IPointer_k, KEY, KVL_ ## TAG ##_kitt) \ - Instantiate_TStructIterator_T(KVL_ ## TAG ## _t, KVL_ ## TAG ## _t::IPointer, KVI_ ## TAG ## _t, KVL_ ## TAG ##_itt) \ - Instantiate_TIterator_T(KVL_ ## TAG ## _t, KVL_ ## TAG ## _t::IPointer, KVI_ ## TAG ## _t, KVL_ ## TAG ##_itt) \ - Instantiate_TList(KVI_ ## TAG ## _t) - -// template ostream & operator<<(ostream &s, EST_TKVI const &i); - -#define Instantiate_KVL(KEY, VAL) \ - Instantiate_KVL_T(KEY, VAL, KEY ## VAL) - -#define Declare_KVL_TN(KEY, VAL, MaxFree, TAG) \ - typedef EST_TKVI KVI_ ## TAG ## _t; \ - typedef EST_TKVL KVL_ ## TAG ## _t; \ - \ - static VAL TAG##_kv_def_val_s; \ - static KEY TAG##_kv_def_key_s; \ - \ - template <> VAL *EST_TKVL< KEY, VAL >::default_val=&TAG##_kv_def_val_s; \ - template <> KEY *EST_TKVL< KEY, VAL >::default_key=&TAG##_kv_def_key_s; \ - \ - Declare_TList_N(KVI_ ## TAG ## _t, MaxFree) -#define Declare_KVL_T(KEY, VAL, TAG) \ - Declare_KVL_TN(KEY, VAL, 0, TAG) - -#define Declare_KVL_Base_TN(KEY, VAL, DEFV, DEFK, MaxFree, TAG) \ - typedef EST_TKVI KVI_ ## TAG ## _t; \ - typedef EST_TKVL KVL_ ## TAG ## _t; \ - \ - static VAL TAG##_kv_def_val_s=DEFV; \ - static KEY TAG##_kv_def_key_s=DEFK; \ - \ - template <> VAL *EST_TKVL< KEY, VAL >::default_val=&TAG##_kv_def_val_s; \ - template <> KEY *EST_TKVL< KEY, VAL >::default_key=&TAG##_kv_def_key_s; \ - \ - Declare_TList_N(KVI_ ## TAG ## _t, MaxFree) -#define Declare_KVL_Base_T(KEY, VAL, DEFV, DEFK, TAG) \ - Declare_KVL_Base_TN(KEY, VAL, DEFV, DEFK, 0, TAG) - -#define Declare_KVL_Class_TN(KEY, VAL, DEFV, DEFK, MaxFree, TAG) \ - typedef EST_TKVI KVI_ ## TAG ## _t; \ - typedef EST_TKVL KVL_ ## TAG ## _t; \ - \ - static VAL TAG##_kv_def_val_s(DEFV); \ - static KEY TAG##_kv_def_key_s(DEFK); \ - \ - template <> VAL *EST_TKVL< KEY, VAL >::default_val=&TAG##_kv_def_val_s; \ - template <> KEY *EST_TKVL< KEY, VAL >::default_key=&TAG##_kv_def_key_s; \ - \ - Declare_TList_N(KVI_ ## TAG ## _t, MaxFree) -#define Declare_KVL_Class_T(KEY, VAL, DEFV, DEFK,TAG) \ - Declare_KVL_Class_TN(KEY, VAL, DEFV, DEFK, 0, TAG) - -#define Declare_KVL_N(KEY, VAL, MaxFree) \ - Declare_KVL_TN(KEY, VAL, MaxFree, KEY ## VAL) -#define Declare_KVL(KEY, VAL) \ - Declare_KVL_N(KEY, VAL, 0) - -#define Declare_KVL_Base_N(KEY, VAL, DEFV, DEFK, MaxFree) \ - Declare_KVL_Base_TN(KEY, VAL, DEFV, DEFK, , MaxFree, KEY ## VAL) -#define Declare_KVL_Base(KEY, VAL, DEFV, DEFK) \ - Declare_KVL_Base_N(KEY, VAL, DEFV, DEFK, 0) - -#define Declare_KVL_Class_N(KEY, VAL, DEFV, DEFK, MaxFree) \ - Declare_KVL_Class_TN(KEY, VAL, DEFV, DEFK, MaxFree, KEY ## VAL) -#define Declare_KVL_Class(KEY, VAL, DEFV, DEFK) \ - Declare_KVL_Class_N(KEY, VAL, DEFV, DEFK, 0) - -#endif - diff --git a/src/est/EST_TList.h b/src/est/EST_TList.h deleted file mode 100644 index c6a96a8169..0000000000 --- a/src/est/EST_TList.h +++ /dev/null @@ -1,315 +0,0 @@ - /*************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1995,1996 */ - /* All Rights Reserved. */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - /* */ - /* Author : Paul Taylor */ - /* Date : April 1995 */ - /* --------------------------------------------------------------------- */ - /* Double linked list class */ - /* */ - /* Modified by RJC, 21/7/97. Now much of the working code is in the */ - /* UList class, this template class provides a type safe front end to */ - /* the untyped list. */ - /* */ - /*************************************************************************/ - -#ifndef __Tlist_H__ -#define __Tlist_H__ - -#include -#include "EST_common.h" -#include "EST_UList.h" -#include "EST_TSortable.h" -#include "EST_TIterator.h" - -#include "EST_TListI.h" - -class EST_String; - -template class EST_TList; - -template class EST_TItem : public EST_UItem { -private: - static void *operator new(size_t not_used, void *place) - {(void)not_used; return place;} - static void *operator new(size_t size) - {return malloc(size);} - static void operator delete(void *p) - {free(p);} - - static EST_TItem *s_free; - static unsigned int s_nfree; - static unsigned int s_maxFree; - -protected: - static EST_TItem *make(const T &val); - static void release(EST_TItem *it); - - friend class EST_TList; - -public: - T val; - - EST_TItem(const T &v) : val(v) - { init(); }; - EST_TItem() - { init();}; -}; - -// pretty name - -typedef EST_UItem EST_Litem; - -/** - -A Template doubly linked list class. This class contains doubly linked -lists of a type denoted by {\tt T}. A pointer of type \Ref{EST_Litem} -is used to access items in the list. The class supports a variety of -ways of adding, removing and accessing items in the list. For examples -of how to operate lists, see \Ref{list_example}. - -Iteration through the list is performed using a pointer of type -\Ref{EST_Litem}. See \Ref{Iteration} for example code. - -*/ - -template class EST_TList : public EST_UList -{ - private: - void copy_items(const EST_TList &l); - public: - void init() { EST_UList::init(); }; - static void free_item(EST_UItem *item); - - /**@name Constructor functions */ - //@{ - /// default constructor - EST_TList() { }; - /// copy constructor - EST_TList(const EST_TList &l); - ~ EST_TList() { clear_and_free(free_item); } - //@} - - /**@name Access functions for reading and writing items. - See \Ref{EST_TList_Accessing} for examples.*/ - - //@{ - - /** return the value associated with the EST_Litem pointer. This - has the same functionality as the overloaded () operator. - */ - T &item(const EST_Litem *p) - { return ((EST_TItem *)p) -> val; }; - /** return a const value associated with the EST_Litem pointer.*/ - const T &item(const EST_Litem *p) const - { return ((EST_TItem *)p) -> val; }; - /// return the Nth value - T &nth(int n) - { return item(nth_pointer(n)); }; - /// return a const Nth value - const T &nth(int n) const - { return item(nth_pointer(n)); }; - - /// return const reference to first item in list - const T &first() const - { return item(head()); }; - /// return const reference to last item in list - const T &last() const - { return item(tail()); }; - /** return reference to first item in list - * @see last - */ - T &first() - { return item(head()); }; - /// return reference to last item in list - T &last() - { return item(tail()); }; - - /// return const reference to item in list pointed to by {\tt ptr} - const T &operator () (const EST_Litem *ptr) const - { return item(ptr); }; - /// return non-const reference to item in list pointed to by {\tt ptr} - T &operator () (const EST_Litem *ptr) - { return item(ptr); }; - - //@} - - /**@name Removing items in a list. - more. - */ - //@{ - /** remove item pointed to by {\tt ptr}, return pointer to previous item. - See \Ref{Removing} for example code.*/ - EST_Litem *remove(EST_Litem *ptr) - { return EST_UList::remove(ptr, free_item); }; - - /// remove nth item, return pointer to previous item - EST_Litem *remove_nth(int n) - { return EST_UList::remove(n, free_item); }; - - //@} - - - /**@name Adding items to a list. - In all cases, a complete copy of - the item is made and added to the list. See \Ref{Addition} for examples. - */ - //@{ - /// add item onto end of list - void append(const T &item) - { EST_UList::append(EST_TItem::make(item)); }; - /// add item onto start of list - void prepend(const T &item) - { EST_UList::prepend(EST_TItem::make(item)); }; - - /** add {\tt item} after position given by {\tt ptr}, return pointer - to added item. */ - - EST_Litem *insert_after(EST_Litem *ptr, const T &item) - { return EST_UList::insert_after(ptr, EST_TItem::make(item)); }; - - /** add {\tt item} before position given by {\tt ptr}, return - pointer to added item. */ - - EST_Litem *insert_before(EST_Litem *ptr, const T &item) - { return EST_UList::insert_before(ptr, EST_TItem::make(item)); }; - - //@} - - /**@name Exchange */ - //@{ - /// exchange 1 - void exchange(EST_Litem *a, EST_Litem *b) - { EST_UList::exchange(a, b); }; - /// exchange 2 - void exchange(int i, int j) - { EST_UList::exchange(i,j); }; - /// exchange 3 - static void exchange_contents(EST_Litem *a, EST_Litem *b); - //@} - - /**@name General functions */ - //@{ - /// make full copy of list - EST_TList &operator=(const EST_TList &a); - /// Add list onto end of existing list - EST_TList &operator +=(const EST_TList &a); - - /// print list - friend ostream& operator << (ostream &st, EST_TList const &list); - - /// remove all items in list - void clear(void) - { clear_and_free(free_item); }; - //@} - - // Iteration support - -protected: - struct IPointer { EST_Litem *p; }; - - void point_to_first(IPointer &ip) const { ip.p = head(); } - void move_pointer_forwards(IPointer &ip) const { ip.p = next(ip.p); } - bool points_to_something(const IPointer &ip) const { return ip.p != NULL; } - T &points_at(const IPointer &ip) { return item(ip.p); } - - friend class EST_TIterator< EST_TList, IPointer, T >; - friend class EST_TRwIterator< EST_TList, IPointer, T >; - -public: - typedef T Entry; - typedef EST_TIterator< EST_TList, IPointer, T > Entries; - typedef EST_TRwIterator< EST_TList, IPointer, T > RwEntries; - -}; - - -template -extern ostream& operator << (ostream &st, EST_TList< T > const &list); - -template -bool operator==(const EST_TList &a, const EST_TList &b) -{ - return EST_UList::operator_eq(a, b, EST_TSortable::items_eq); -} - -template -int index(EST_TList &l, T& val, bool (*eq)(const EST_UItem *, const EST_UItem *) = NULL) -{ - EST_TItem item(val); - return EST_UList::index(l, item, eq?eq:EST_TSortable::items_eq); -} - -template -void sort(EST_TList &a, bool (*gt)(const EST_UItem *, const EST_UItem *) = NULL) -{ - EST_UList::sort(a, gt?gt:EST_TSortable::items_gt); -} - -template -void ptr_sort(EST_TList &a) -{ - EST_UList::sort(a, EST_TSortable::items_gt); -} - -template -void qsort(EST_TList &a, bool (*gt)(const EST_UItem *, const EST_UItem *) = NULL) -{ - EST_UList::qsort(a, gt?gt:EST_TSortable::items_gt, EST_TList::exchange_contents); -} - -template -void ptr_qsort(EST_TList &a) -{ - EST_UList::qsort(a, EST_TSortable::items_gt, EST_TList::exchange_contents); -} - -template -void sort_unique(EST_TList &l) -{ - EST_UList::sort_unique(l, - EST_TSortable::items_eq, - EST_TSortable::items_gt, - EST_TList::free_item); -} - -template -void merge_sort_unique(EST_TList &l, EST_TList &m) -{ - EST_UList::merge_sort_unique(l, m, - EST_TSortable::items_eq, - EST_TSortable::items_gt, - EST_TList::free_item); -} - -template -const char *error_name(EST_TList val) { (void)val; return "<>"; } - -#endif diff --git a/src/est/EST_TListI.h b/src/est/EST_TListI.h deleted file mode 100644 index 9e2f54030a..0000000000 --- a/src/est/EST_TListI.h +++ /dev/null @@ -1,92 +0,0 @@ - - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - - -#ifndef __EST_TLIST_I_H__ -#define __EST_TLIST_I_H__ - -/** Instantiate rules for list template. - * - * @author Richard Caley - * @version $Id: EST_TListI.h,v 1.3 2004/05/04 00:00:17 awb Exp $ - */ - - -// Instantiation Macros - -#include -#include "EST_TIteratorI.h" - -#define Instantiate_TList_T_MIN(TYPE, TAG) \ - template class EST_TList< TLIST_ ## TAG ## _VAL >; \ - template class EST_TItem< TLIST_ ## TAG ## _VAL >; \ - template const char *error_name(EST_TList< TYPE > val); \ - Instantiate_TIterator_T( EST_TList, EST_TList::IPointer, TYPE, TList_ ## TAG ## _itt); - -#define Instantiate_TList_T(TYPE, TAG) \ - Instantiate_TList_T_MIN(TYPE, TAG) \ - \ - ostream& operator << (ostream &st, EST_TList< TYPE > const &list) { EST_Litem *ptr; for (ptr = list.head(); ptr != 0; ptr = next(ptr)) st << list.item(ptr) << " "; return st;} - - -#define Instantiate_TList(TYPE) Instantiate_TList_T(TYPE, TYPE) - -#define Declare_TList_TN(TYPE,MaxFree,TAG) \ - typedef TYPE TLIST_ ## TAG ## _VAL; \ - template <> EST_TItem< TYPE > * EST_TItem< TYPE >::s_free=NULL; \ - template <> unsigned int EST_TItem< TYPE >::s_maxFree=MaxFree; \ - template <> unsigned int EST_TItem< TYPE >::s_nfree=0; -#define Declare_TList_T(TYPE,TAG) \ - Declare_TList_TN(TYPE,0,TAG) - -#define Declare_TList_Base_TN(TYPE,MaxFree,TAG) \ - Declare_TList_TN(TYPE,MaxFree,TAG) -#define Declare_TList_Base_T(TYPE,TAG) \ - Declare_TList_Base_TN(TYPE,0,TAG) \ - -#define Declare_TList_Class_TN(TYPE,MaxFree,TAG) \ - Declare_TList_TN(TYPE,MaxFree,TAG) -#define Declare_TList_Class_T(TYPE,TAG) \ - Declare_TList_Class_TN(TYPE,0,TAG) \ - -#define Declare_TList_N(TYPE,MaxFree) Declare_TList_TN(TYPE,MaxFree,TYPE) -#define Declare_TList_Base_N(TYPE,MaxFree) Declare_TList_Base_TN(TYPE,MaxFree,TYPE) -#define Declare_TList_Class_N(TYPE,MaxFree) Declare_TList_Class_TN(TYPE,MaxFree,TYPE) - -#define Declare_TList(TYPE) Declare_TList_N(TYPE,0) -#define Declare_TList_Base(TYPE) Declare_TList_Base_N(TYPE,0) -#define Declare_TList_Class(TYPE) Declare_TList_Class_N(TYPE,0) - -#endif - diff --git a/src/est/EST_TMatrix.h b/src/est/EST_TMatrix.h deleted file mode 100644 index e7f1cd379a..0000000000 --- a/src/est/EST_TMatrix.h +++ /dev/null @@ -1,321 +0,0 @@ - /*************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - /* */ - /* Author : Paul Taylor */ - /* Rewritten : Richard Caley */ - /* --------------------------------------------------------------------- */ - /* Matrix class */ - /* */ - /*************************************************************************/ - -#ifndef __TMatrix_H__ -#define __TMatrix_H__ - -#include -#include "EST_rw_status.h" -#include "EST_TVector.h" -#include "EST_TMatrixI.h" - -/* When set bounds checks (safe but slow) are done on matrix access */ -#ifndef TMATRIX_BOUNDS_CHECKING -# define TMATRIX_BOUNDS_CHECKING 0 -#endif - -#if TMATRIX_BOUNDS_CHECKING -#define A_CHECK a_check -#else -#define A_CHECK a_no_check -#endif - -#define INLINE inline - -/* This doesn't work as I thought so I have disabled it for now. - */ - -#if defined(__GNUC__) && 0 -# define mx_move_pointer(P, TY, STEP, N) \ - ((TY *)\ - ((void *) (((char (*) [sizeof(TY)*STEP])P) + N) ) \ - ) -# define fast_a_m_gcc(R,C) \ - ( * mx_move_pointer(mx_move_pointer(p_memory,T,p_column_step,C),T,p_row_step,R)) -# define fast_a_m_x(R,C) (fast_a_m_gcc(R,C)) -#else -# define fast_a_m_x(R,C) (fast_a_m(R,C)) -#endif - - - -/** Template Matrix class. - * - * This is an extension of the EST_TVector class to two dimensions. - * - * @see matrix_example - * @see EST_TVector - */ - -template -class EST_TMatrix : public EST_TVector -{ - -protected: - /// Visible shape - unsigned int p_num_rows; - - /// How to access the memory - unsigned int p_row_step; - - INLINE unsigned int mcell_pos(int r, int c, - int rs, int cs) const - { return (rs==1?r:(r*rs)) + (cs==1?c:(c*cs));} - - - INLINE unsigned int mcell_pos(int r, int c) const - { - - return mcell_pos(r, c, - this->p_row_step, this->p_column_step); - } - - INLINE unsigned int mcell_pos_1(int r, int c) const - { - - (void)r; - return c; - } - - /// quick method for returning {\tt x[m][n]} - INLINE const T &fast_a_m(int r, int c) const - { return this->p_memory[mcell_pos(r,c)]; } - INLINE T &fast_a_m(int r, int c) - { return this->p_memory[mcell_pos(r,c)]; } - - INLINE const T &fast_a_1(int r, int c) const - { return this->p_memory[mcell_pos_1(r,c)]; } - INLINE T &fast_a_1(int r, int c) - { return this->p_memory[mcell_pos_1(r,c)]; } - - - /// Get and set values from array - void set_values(const T *data, - int r_step, int c_step, - int start_r, int num_r, - int start_c, int num_c - ); - void get_values(T *data, - int r_step, int c_step, - int start_r, int num_r, - int start_c, int num_c - ) const; - - /// private resize and copy function. - void copy(const EST_TMatrix &a); - /// just copy data, no resizing, no size check. - void copy_data(const EST_TMatrix &a); - - /// resize the memory and reset the bounds, but don't set values. - void just_resize(int new_rows, int new_cols, T** old_vals); - - /// sets data and length to default values (0 in both cases). - void default_vals(); -public: - - ///default constructor - EST_TMatrix(); - - /// copy constructor - EST_TMatrix(const EST_TMatrix &m); - - /// "size" constructor - EST_TMatrix(int rows, int cols); - - /// construct from memory supplied by caller - EST_TMatrix(int rows, int cols, - T *memory, int offset=0, int free_when_destroyed=0); - - /// EST_TMatrix - - ~EST_TMatrix(); - - /**@name access - * Basic access methods for matrices. - */ - //@{ - - /// return number of rows - int num_rows() const {return this->p_num_rows;} - /// return number of columns - int num_columns() const {return this->p_num_columns;} - - /// const access with no bounds check, care recommend - INLINE const T &a_no_check(int row, int col) const - { return fast_a_m_x(row,col); } - /// access with no bounds check, care recommend - INLINE T &a_no_check(int row, int col) - { return fast_a_m_x(row,col); } - - INLINE const T &a_no_check_1(int row, int col) const { return fast_a_1(row,col); } - INLINE T &a_no_check_1(int row, int col) { return fast_a_1(row,col); } - - /// const element access function - const T &a_check(int row, int col) const; - /// non-const element access function - T &a_check(int row, int col); - - const T &a(int row, int col) const { return A_CHECK(row,col); } - T &a(int row, int col) { return A_CHECK(row,col); } - - /// const element access operator - const T &operator () (int row, int col) const { return a(row,col); } - /// non-const element access operator - T &operator () (int row, int col) { return a(row,col); } - - //@} - - bool have_rows_before(int n) const; - bool have_columns_before(int n) const; - - /** resize matrix. If {\tt set=1}, then the current values in - the matrix are preserved up to the new size {\tt n}. If the - new size exceeds the old size, the rest of the matrix is - filled with the {\tt def_val} - */ - void resize(int rows, int cols, int set=1); - - /// fill matrix with value v - void fill(const T &v); - void fill() { fill(*this->def_val); } - - /// assignment operator - EST_TMatrix &operator=(const EST_TMatrix &s); - - /// The two versions of what might have been operator += - EST_TMatrix &add_rows(const EST_TMatrix &s); - EST_TMatrix &add_columns(const EST_TMatrix &s); - - /**@name Sub-Matrix/Vector Extraction - * - * All of these return matrices and vectors which share - * memory with the original, so altering values them alters - * the original. - */ - //@{ - - /// Make the vector {\tt rv} a window onto row {\tt r} - void row(EST_TVector &rv, int r, int start_c=0, int len=-1); - /// Make the vector {\tt cv} a window onto column {\tt c} - void column(EST_TVector &cv, int c, int start_r=0, int len=-1); - /// Make the matrix {\tt sm} a window into this matrix. - void sub_matrix(EST_TMatrix &sm, - int r=0, int numr=EST_ALL, - int c=0, int numc=EST_ALL); - //@} - - /**@name Copy in and out - * Copy data between buffers and the matrix. - */ - //@{ - /** Copy row {\tt r} of matrix to {\tt buf}. {\tt buf} - should be pre-malloced to the correct size. - */ - void copy_row(int r, T *buf, int offset=0, int num=-1) const; - - /** Copy row r of matrix to - buf. buf should be - pre-malloced to the correct size. */ - - void copy_row(int r, EST_TVector &t, int offset=0, int num=-1) const; - - /** Copy column {\tt c} of matrix to {\tt buf}. {\tt buf} - should be pre-malloced to the correct size. - */ - void copy_column(int c, T *buf, int offset=0, int num=-1) const; - - /** Copy column c of matrix to - buf. buf should - be pre-malloced to the correct size. */ - - void copy_column(int c, EST_TVector &t, int offset=0, int num=-1)const; - - /** Copy buf into row {\tt n} of matrix. - */ - void set_row(int n, const T *buf, int offset=0, int num=-1); - - void set_row(int n, const EST_TVector &t, int offset=0, int num=-1) - { set_row(n, t.memory(), offset, num); } - - void set_row(int r, - const EST_TMatrix &from, int from_r, int from_offset=0, - int offset=0, int num=-1); // set nth row - - - /** Copy buf into column {\tt n} of matrix. - */ - void set_column(int n, const T *buf, int offset=0, int num=-1); - - void set_column(int n, const EST_TVector &t, int offset=0, int num=-1) - { set_column(n, t.memory(), offset, num); } - - void set_column(int c, - const EST_TMatrix &from, int from_c, int from_offset=0, - int offset=0, int num=-1); // set nth column - - /** For when you absolutely have to have access to the memory. - */ - void set_memory(T *buffer, int offset, int rows, int columns, - int free_when_destroyed=0); - - //@} - - /**@name io - * Matrix file io. - */ - //@{ - /// load Matrix from file - Not currently implemented. - EST_read_status load(const class EST_String &filename); - /// save Matrix to file {\tt filename} - EST_write_status save(const class EST_String &filename) const; - - /// print matrix. - friend ostream& operator << (ostream &st,const EST_TMatrix &a); - //@} - -}; - -#undef A_CHECK - -template -extern ostream& operator << (ostream &st,const EST_TMatrix &a); - -#endif - diff --git a/src/est/EST_TMatrixI.h b/src/est/EST_TMatrixI.h deleted file mode 100644 index b74d7a5d09..0000000000 --- a/src/est/EST_TMatrixI.h +++ /dev/null @@ -1,64 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - - -#ifndef __EST_TMATRIX_I_H__ -#define __EST_TMATRIX_I_H__ - -/** Instantiate rules for matrix template. - * - * @author Richard Caley - * @version $Id: EST_TMatrixI.h,v 1.2 2001/04/04 13:11:27 awb Exp $ - */ - - - - -// Instantiation Macros - -#define Instantiate_TMatrix(TYPE) \ - template class EST_TMatrix< TYPE >; \ - \ - ostream& operator << (ostream &st, const EST_TMatrix< TYPE > &a) {int i, j; for (i = 0; i < a.num_rows(); ++i) {for (j = 0; j < a.num_columns(); ++j) st << a.a_no_check(i, j) << " "; st << endl;} return st;} - -#define Declare_TMatrix_T(TYPE,TAG) -#define Declare_TMatrix_Base_T(TYPE,DEFAULT,ERROR,TAG) - -#define Declare_TMatrix_Class_T(TYPE,DEFAULT,ERROR,TAG) - -#define Declare_TMatrix(TYPE) Declare_TMatrix_T(TYPE,TYPE) -#define Declare_TMatrix_Base(TYPE,DEFAULT,ERROR) Declare_TMatrix_Base_T(TYPE,DEFAULT,ERROR,TYPE) -#define Declare_TMatrix_Class(TYPE,DEFAULT,ERROR) Declare_TMatrix_Class_T(TYPE,DEFAULT,ERROR,TYPE) - -#endif - diff --git a/src/est/EST_TNamedEnum.h b/src/est/EST_TNamedEnum.h deleted file mode 100644 index 50e428cb0b..0000000000 --- a/src/est/EST_TNamedEnum.h +++ /dev/null @@ -1,166 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /************************************************************************/ - /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */ - /* Date: Fri Feb 28 1997 */ - /************************************************************************/ - /* */ - /* A template class which allows names (const char *s) to be */ - /* associated with enums, providing conversion. */ - /* */ - /* EST_TValuesEnum is the obvious generalisation to associating */ - /* things other than const char * with each value. */ - /* */ - /* EST_T{Named/Valued}EnumI can include extra information for each */ - /* enum element. */ - /* */ - /* This should be rewritten as something other than linear search. At */ - /* least sort them. */ - /* */ - /************************************************************************/ - -#ifndef __EST_TNAMEDENUM_H__ -#define __EST_TNAMEDENUM_H__ - -#include -#include "EST_String.h" -#include "EST_rw_status.h" - -#define NAMED_ENUM_MAX_SYNONYMS (10) - -// Used in the type of tables with no info field. - -typedef char NO_INFO; - -// struct used to define the mapping. - -template -struct EST_TValuedEnumDefinition { -public: - ENUM token; - VAL values[NAMED_ENUM_MAX_SYNONYMS]; - INFO info; -} ; - -// This is the most general case, a mapping from enum to some other type -// with extra info. - -template class EST_TValuedEnumI { - -protected: - int ndefinitions; - ENUM p_unknown_enum; - VAL p_unknown_value; - EST_TValuedEnumDefinition *definitions; - - virtual int eq_vals(VAL v1, VAL v2) const {return v1 == v2; }; - // This is only a void * because INFO can`t manage to get the - // parameter declaration in the definition past gcc with the actual type. - void initialise(const void *defs); - void initialise(const void *defs, ENUM (*conv)(const char *)); - void initialise(void) {ndefinitions=0; definitions=NULL;}; - void initialise(ENUM unknown_e, VAL unknown_v) {initialise(); p_unknown_enum=unknown_e; p_unknown_value = unknown_v;}; - -protected: - EST_TValuedEnumI(void) {initialise();}; - -public: - EST_TValuedEnumI(EST_TValuedEnumDefinition defs[]) - {initialise((const void *)defs); }; - EST_TValuedEnumI(EST_TValuedEnumDefinition defs[], ENUM (*conv)(const char *)) - {initialise((const void *)defs, conv); }; - virtual ~EST_TValuedEnumI(void); - - int n(void) const; - - ENUM token(VAL value) const; - ENUM token(int n) const { return nth_token(n); } - ENUM nth_token(int n) const; - VAL value(ENUM token, int n=0) const; - INFO &info(ENUM token) const; - - ENUM unknown_enum(void) const {return p_unknown_enum;}; - VAL unknown_value(void) const {return p_unknown_value;}; - int valid(ENUM token) const { return !eq_vals(value(token),p_unknown_value); }; -}; - -// This is a special case for names. This saves typing and also -// takes care of the fact that strings need their own compare function. - -template class EST_TNamedEnumI : public EST_TValuedEnumI { - -protected: - EST_TNamedEnumI(void) : EST_TValuedEnumI() {}; - int eq_vals(const char *v1, const char *v2) const {return strcmp(v1,v2) ==0; }; -public: - - EST_TNamedEnumI(EST_TValuedEnumDefinition defs[]) - {this->initialise((const void *)defs); }; - EST_TNamedEnumI(EST_TValuedEnumDefinition defs[], ENUM (*conv)(const char *)) - {this->initialise((const void *)defs, conv); }; - const char *name(ENUM tok, int n=0) const {return value(tok,n); }; - -}; - -// Now the simple cases with no extra information - -template class EST_TValuedEnum : public EST_TValuedEnumI { -public: - EST_TValuedEnum(EST_TValuedEnumDefinition defs[]) - {this->initialise((const void *)defs);}; - EST_TValuedEnum(EST_TValuedEnumDefinition defs[], ENUM (*conv)(const char *)) - {this->initialise((const void *)defs, conv);}; -}; - - -template class EST_TNamedEnum : public EST_TNamedEnumI { -private: - EST_read_status priv_load(EST_String name, EST_TNamedEnum *definitive); - EST_write_status priv_save(EST_String name, EST_TNamedEnum *definitive, char quote) const; -public: - EST_TNamedEnum(ENUM undef_e, const char *undef_n = NULL) - {this->initialise(undef_e, undef_n);}; - EST_TNamedEnum(EST_TValuedEnumDefinition defs[]) - {this->initialise((const void *)defs);}; - EST_TNamedEnum(EST_TValuedEnumDefinition defs[], ENUM (*conv)(const char *)) - {this->initialise((const void *)defs, conv);}; - - EST_read_status load(EST_String name) { return priv_load(name, NULL); }; - EST_read_status load(EST_String name, EST_TNamedEnum &definitive) { return priv_load(name, &definitive); }; - EST_write_status save(EST_String name, char quote='"') const { return priv_save(name, NULL, quote); }; - EST_write_status save(EST_String name, EST_TNamedEnum &definitive, char quote='"') const { return priv_save(name, &definitive, quote); }; - -}; - -#include "EST_TNamedEnumI.h" - -#endif diff --git a/src/est/EST_TNamedEnumI.h b/src/est/EST_TNamedEnumI.h deleted file mode 100644 index 8436e733e0..0000000000 --- a/src/est/EST_TNamedEnumI.h +++ /dev/null @@ -1,157 +0,0 @@ - - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - - -#ifndef __EST_TNamedEnum_I_H__ -#define __EST_TNamedEnum_I_H__ - -/** Instantiate rules for named enum template. - * - * @author Richard Caley - * @version $Id: EST_TNamedEnumI.h,v 1.2 2001/04/04 13:11:27 awb Exp $ - */ - -// Instantiation Macros - -#define Instantiate_TValuedEnumI_T(ENUM, VAL, INFO, TAG) \ - template class EST_TValuedEnumI< ENUM, VAL, INFO >; \ - - -#define Instantiate_TValuedEnum_T(ENUM, VAL, TAG) \ - Instantiate_TValuedEnumI_T(ENUM, VAL, NO_INFO, TAG) - -#define Instantiate_TNamedEnumI_T(ENUM, INFO, TAG) \ - template class EST_TNamedEnumI< ENUM, INFO >; \ - Instantiate_TValuedEnumI_T(ENUM, const char *, INFO, TAG) - -#define Instantiate_TNamedEnum_T(ENUM, TAG) \ - Instantiate_TValuedEnumI_T(ENUM, const char *, NO_INFO, TAG) \ - template class EST_TNamedEnum< ENUM >; \ - template class EST_TNamedEnumI< ENUM, NO_INFO >; - - -#define Instantiate_TValuedEnumI(ENUM, VAL, INFO) \ - Instantiate_TValuedEnumI_T(ENUM, VAL, INFO, ENUM ## VAL ## INFO ) - -#define Instantiate_TValuedEnum(ENUM, VAL) \ - template class EST_TValuedEnum< ENUM, VAL >; \ - Instantiate_TValuedEnum_T(ENUM, VAL, ENUM ## VAL) - - -#define Instantiate_TNamedEnumI(ENUM, INFO) \ - Instantiate_TNamedEnumI_T(ENUM, INFO, ENUM ## INFO) - -#define Instantiate_TNamedEnum(ENUM) \ - Instantiate_TNamedEnum_T(ENUM, ENUM) \ - -// declaration macros. NULL at the moment. - -#define Declare_TValuedEnumI_T(ENUM, VAL, INFO, TAG) \ - /* EMPTY */ - -#define Declare_TValuedEnum_T(ENUM, VAL, TAG) \ - Declare_TValuedEnumI_T(ENUM, VAL, NO_INFO, TAG) - -#define Declare_TNamedEnumI_T(ENUM, INFO, TAG) \ - Declare_TValuedEnumI_T(ENUM, const char *, INFO, TAG) - -#define Declare_TNamedEnum_T(ENUM, TAG) \ - Declare_TNamedEnumI_T(ENUM, NO_INFO, TAG) - - -#define Declare_TValuedEnumI(ENUM, VAL, INFO) \ - Declare_TValuedEnumI_T(ENUM, VAL, INFO, ENUM ## VAL ## INFO ) - -#define Declare_TValuedEnum(ENUM, VAL) \ - Declare_TValuedEnum_T(ENUM, VAL, ENUM ## VAL) - -#define Declare_TNamedEnumI(ENUM, INFO) \ - Declare_TNamedEnumI_T(ENUM, INFO, ENUM ## INFO) - -#define Declare_TNamedEnum(ENUM) \ - Declare_TNamedEnum_T(ENUM, ENUM) - -// Actual table declaration macros - -#define Create_TValuedEnumDefinition(ENUM, VAL, INFO, TAG) \ - static EST_TValuedEnumDefinition< ENUM, VAL, INFO> TAG ## _names[] - -#define Create_TNamedEnumDefinition(ENUM, INFO, TAG) \ - Create_TValuedEnumDefinition(ENUM, const char *, INFO, TAG) - -#define Start_TValuedEnumI_T(ENUM, VAL, INFO, NAME, TAG) \ - Create_TValuedEnumDefinition(ENUM, VAL, INFO, TAG) = { -#define End_TValuedEnumI_T(ENUM, VAL, INFO, NAME, TAG) \ - }; \ - EST_TValuedEnumI< ENUM, VAL, INFO > NAME (TAG ## _names); - -#define Start_TNamedEnumI_T(ENUM, INFO, NAME, TAG) \ - Create_TValuedEnumDefinition(ENUM, const char *, INFO, TAG) = { -#define End_TNamedEnumI_T(ENUM, INFO, NAME, TAG) \ - }; \ - EST_TNamedEnumI< ENUM, INFO > NAME (TAG ## _names); - -#define Start_TValuedEnumI(ENUM, VAL, INFO, NAME) \ - Start_TValuedEnumI_T(ENUM, VAL, INFO, NAME, NAME) -#define End_TValuedEnumI(ENUM, VAL, INFO, NAME) \ - End_TValuedEnumI_T(ENUM, VAL, INFO, NAME, NAME) - -#define Start_TNamedEnumI(ENUM, INFO, NAME) \ - Start_TNamedEnumI_T(ENUM, INFO, NAME, NAME) -#define End_TNamedEnumI(ENUM, INFO, NAME) \ - End_TNamedEnumI_T(ENUM, INFO, NAME, NAME) - -#define Start_TValuedEnum_T(ENUM, VAL, NAME, TAG) \ - Create_TValuedEnumDefinition(ENUM, VAL, NO_INFO, TAG) = { -#define End_TValuedEnum_T(ENUM, VAL, NAME, TAG) \ - }; \ - EST_TValuedEnum< ENUM, VAL > NAME (TAG ## _names); - -#define Start_TNamedEnum_T(ENUM, NAME, TAG) \ - Create_TValuedEnumDefinition(ENUM, const char *, NO_INFO, TAG) = { -#define End_TNamedEnum_T(ENUM, NAME, TAG) \ - }; \ - EST_TNamedEnum< ENUM > NAME (TAG ## _names); - -#define Start_TValuedEnum(ENUM, VAL, NAME) \ - Start_TValuedEnum_T(ENUM, VAL, NAME, NAME) -#define End_TValuedEnum(ENUM, VAL, NAME) \ - End_TValuedEnum_T(ENUM, VAL, NAME, NAME) - -#define Start_TNamedEnum(ENUM, NAME) \ - Start_TNamedEnum_T(ENUM, NAME, NAME) -#define End_TNamedEnum(ENUM, NAME) \ - End_TNamedEnum_T(ENUM, NAME, NAME) -#endif - diff --git a/src/est/EST_TSimpleMatrix.h b/src/est/EST_TSimpleMatrix.h deleted file mode 100644 index c6ab56e1cc..0000000000 --- a/src/est/EST_TSimpleMatrix.h +++ /dev/null @@ -1,74 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - /* */ - /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */ - /* Date: Fri Oct 10 1997 */ - /* -------------------------------------------------------------------- */ - /* A subclass of TMatrix which copies using memcopy. This isn't */ - /* suitable for matrices of class objects which have to be copied */ - /* using a constructor or specialised assignment operator. */ - /* */ - /*************************************************************************/ - -#ifndef __EST_TSIMPLEMATRIX_H__ -#define __EST_TSIMPLEMATRIX_H__ - -#include "EST_TMatrix.h" -#include "EST_TSimpleMatrixI.h" - -template -class EST_TSimpleMatrix : public EST_TMatrix { -protected: - - // just copy data, no resizing. - void copy_data(const EST_TSimpleMatrix &a); - -public: - /// default constructor - EST_TSimpleMatrix(void) : EST_TMatrix() {}; - /// size constructor - EST_TSimpleMatrix(int m, int n) : EST_TMatrix(m, n) {}; - /// copy constructor - EST_TSimpleMatrix(const EST_TSimpleMatrix &m); - - /// copy one matrix into another - void copy(const EST_TSimpleMatrix &a); - - /// resize matrix - void resize(int rows, int cols, int set=1); - - /// assignment operator - EST_TSimpleMatrix &operator=(const EST_TSimpleMatrix &s); -}; - -#endif diff --git a/src/est/EST_TSimpleMatrixI.h b/src/est/EST_TSimpleMatrixI.h deleted file mode 100644 index 1bb90ba34c..0000000000 --- a/src/est/EST_TSimpleMatrixI.h +++ /dev/null @@ -1,52 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - - -#ifndef __EST_TSIMPLEMATRIX_I_H__ -#define __EST_TSIMPLEMATRIX_I_H__ - -/** Instantiate rules for simple-matrix template. - * - * @author Richard Caley - * @version $Id: EST_TSimpleMatrixI.h,v 1.2 2001/04/04 13:11:27 awb Exp $ - */ - -#define Instantiate_TSimpleMatrix(TYPE) \ - template class EST_TSimpleMatrix; - -#define Declare_TSimpleMatrix_T(TYPE,TAG) - -#define Declare_TSimpleMatrix(TYPE) Declare_TSimpleMatrix_T(TYPE,TYPE) - -#endif - diff --git a/src/est/EST_TSimpleVector.h b/src/est/EST_TSimpleVector.h deleted file mode 100644 index a3cc091b08..0000000000 --- a/src/est/EST_TSimpleVector.h +++ /dev/null @@ -1,80 +0,0 @@ - /*************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - /* */ - /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */ - /* Date: Fri Oct 10 1997 */ - /* -------------------------------------------------------------------- */ - /* A subclass of TVector which copies using memcopy. This isn't */ - /* suitable for matrices of class objects which have to be copied */ - /* using a constructor or specialised assignment operator. */ - /* */ - /*************************************************************************/ - -#ifndef __EST_TSimpleVector_H__ -#define __EST_TSimpleVector_H__ - -#include "EST_TVector.h" -#include "EST_TSimpleVectorI.h" - -/** A derived class from EST_TVector which is used for -containing simple types, such as float or int. -*/ -template class EST_TSimpleVector : public EST_TVector { -private: - /// private copy function - void copy(const EST_TSimpleVector &a); -public: - ///default constructor - EST_TSimpleVector() : EST_TVector() {}; - /// copy constructor - EST_TSimpleVector(const EST_TSimpleVector &v); - /// "size" constructor - EST_TSimpleVector(int n): EST_TVector(n) {}; - - /// resize vector - void resize(int n, int set=1); - - /// assignment operator - EST_TSimpleVector &operator=(const EST_TSimpleVector &s); - - void copy_section(T* dest, int offset=0, int num=-1) const; - void set_section(const T* src, int offset=0, int num=-1); - - /// Fill entire array with 0 bits. - void zero(void); - - /// Fill vector with default value - void empty(void) { if (*this->def_val == 0) zero(); else fill(*this->def_val); } -}; - -#endif diff --git a/src/est/EST_TSimpleVectorI.h b/src/est/EST_TSimpleVectorI.h deleted file mode 100644 index d4fe570af1..0000000000 --- a/src/est/EST_TSimpleVectorI.h +++ /dev/null @@ -1,52 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - - -#ifndef __EST_TSIMPLEVECTOR_I_H__ -#define __EST_TSIMPLEVECTOR_I_H__ - -/** Instantiate rules for simple-vector template. - * - * @author Richard Caley - * @version $Id: EST_TSimpleVectorI.h,v 1.2 2001/04/04 13:11:27 awb Exp $ - */ - -#define Instantiate_TSimpleVector(TYPE) \ - template class EST_TSimpleVector; \ - -#define Declare_TSimpleVector_T(TYPE,TAG) - -#define Declare_TSimpleVector(TYPE) Declare_TSimpleVector_T(TYPE,TYPE) - -#endif - diff --git a/src/est/EST_TSortable.h b/src/est/EST_TSortable.h deleted file mode 100644 index e70f0ec437..0000000000 --- a/src/est/EST_TSortable.h +++ /dev/null @@ -1,58 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - /* */ - /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */ - /* Date: Thu Sep 4 1997 */ - /* -------------------------------------------------------------------- */ - /* A record which defines a sorting order. */ - /* */ - /*************************************************************************/ - - -#ifndef __EST_TSORTABLE_H__ -#define __EST_TSORTABLE_H__ - -#include "EST_UList.h" -#include "EST_TSortableI.h" - -template -class EST_TSortable -{ -public: - static bool items_eq(const EST_UItem *item1, const EST_UItem *item2); - static bool items_lt(const EST_UItem *item1, const EST_UItem *item2); - static bool items_gt(const EST_UItem *item1, const EST_UItem *item2); -}; - - -#endif diff --git a/src/est/EST_TSortableI.h b/src/est/EST_TSortableI.h deleted file mode 100644 index 49956017f8..0000000000 --- a/src/est/EST_TSortableI.h +++ /dev/null @@ -1,75 +0,0 @@ - - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - - -#ifndef __EST_TSORTABLE_I_H__ -#define __EST_TSORTABLE_I_H__ - -/** Instantiate rules for sortable template. - * - * @author Richard Caley - * @version $Id: EST_TSortableI.h,v 1.2 2001/04/04 13:11:27 awb Exp $ - */ - - -// Instantiation Macros - -#define Instantiate_TSortable_T(TYPE, TAG) \ - template class EST_TSortable; \ - template class EST_TSortable; \ - \ - template void sort(EST_TList &, bool (*gt)(const EST_UItem *, const EST_UItem *)); \ - template void qsort(EST_TList &, bool (*gt)(const EST_UItem *, const EST_UItem *)); \ - template void ptr_sort(EST_TList &a); \ - template void ptr_qsort(EST_TList &a); \ - template void sort_unique(EST_TList &a); \ - template void merge_sort_unique(EST_TList &l, EST_TList &m); \ - \ - template bool operator==(const EST_TList &a, const EST_TList &b); - -#define Instantiate_TSortable(TYPE) Instantiate_TSortable_T(TYPE, TYPE) - -#define Declare_TSortable_T(TYPE,TAG) - -#define Declare_TSortable_Base_T(TYPE,DEFAULT,ERROR,TAG) - -#define Declare_TSortable_Class_T(TYPE,DEFAULT,ERROR,TAG) - -#define Declare_TSortable(TYPE) Declare_TSortable_T(TYPE,TYPE) - -#define Declare_TSortable_Base(TYPE,DEFAULT,ERROR) Declare_TSortable_Base_T(TYPE,DEFAULT,ERROR,TYPE) -#define Declare_TSortable_Class(TYPE,DEFAULT,ERROR) Declare_TSortable_Class_T(TYPE,DEFAULT,ERROR,TYPE) - -#endif - diff --git a/src/est/EST_TVector.h b/src/est/EST_TVector.h deleted file mode 100644 index 6e414677bf..0000000000 --- a/src/est/EST_TVector.h +++ /dev/null @@ -1,330 +0,0 @@ -/*************************************************************************/ -/* */ -/* Centre for Speech Technology Research */ -/* University of Edinburgh, UK */ -/* Copyright (c) 1996 */ -/* All Rights Reserved. */ -/* */ -/* Permission is hereby granted, free of charge, to use and distribute */ -/* this software and its documentation without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of this work, and to */ -/* permit persons to whom this work is furnished to do so, subject to */ -/* the following conditions: */ -/* 1. The code must retain the above copyright notice, this list of */ -/* conditions and the following disclaimer. */ -/* 2. Any modifications must be clearly marked as such. */ -/* 3. Original authors' names are not deleted. */ -/* 4. The authors' names are not used to endorse or promote products */ -/* derived from this software without specific prior written */ -/* permission. */ -/* */ -/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ -/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ -/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ -/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ -/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ -/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ -/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ -/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ -/* THIS SOFTWARE. */ -/* */ -/*************************************************************************/ -/* Author : Paul Taylor */ -/* Date : April 1996 */ -/*-----------------------------------------------------------------------*/ -/* Vector class */ -/* */ -/*=======================================================================*/ - -#ifndef __EST_TVector_H__ -#define __EST_TVector_H__ - -#include -#include "EST_bool.h" -#include "EST_rw_status.h" - -#include "EST_TVectorI.h" - -template class EST_TMatrix; -template class EST_TList; -class EST_String; - -/* A constants to make it clearer what is going on when we pass `-1' - * meaning `current size' or `all the rest' - */ - -extern const int EST_CURRENT; -extern const int EST_ALL; - -/* When set bounds checks (safe but slow) are done on vector access */ -#ifndef TVECTOR_BOUNDS_CHECKING -# define TVECTOR_BOUNDS_CHECKING 0 -#endif - -#if TVECTOR_BOUNDS_CHECKING -#define A_CHECK a_check -#else -#define A_CHECK a_no_check -#endif - -#define INLINE inline - -/* This doesn't work as I thought so I have disabled it for now. - */ - -#if defined(__GNUC__) && 0 -# define fast_a_v_gcc(C) \ - ( *((T *)\ - (((char (*) [sizeof(T)*p_column_step])p_memory) + (C))\ - )) -# define fast_a_v_x(C) (fast_a_v_gcc(C)) -#else -# define fast_a_v_x(C) (fast_a_v(C)) -#endif - - -/**@name Template vector - - This serves as a base class for a vector - of type T. This acts as a higher level - version of a normal C array as defined as float *x etc. - - The vector can be resized after declaration, access can be - with or without bounds checking. Round brackets denote read-only - access (for consts) while square brackets are for read-write access. - In both cases references are returned. - - The standard operators () and [] should be thought of as - having no bounds checking, though they may do so optionally - as a compile time option. The methods a_check and - a_nocheck provide explicit boundary checking/nonchecking, - both const and non-const versions are provided. - - Access through () and [] are guaranteed to be as fast as standard - C arrays (assuming a reasonable optimizing compiler). - - - EST_FVector x(10); - int i; - - for (i=0; i < x.length(); ++i) - x[i] = sqrt((float)i); - - x.resize(20); - - for (i=10; i < x.length(); ++i) - x[i] = sqrt((float)i); - - - - To instantiate a template for a a vector of type {FooBar} - - - #include "../base_class/EST_TVector.cc" - // If you want List to vector conversion (and defined a TList) - #include "../base_class/EST_Tvectlist.cc" - - template class EST_TVector; - template ostream& operator << - (ostream &st, const EST_TVector &v); - - - The EST library already has template vector instantiations for - int, float, double and - . Also types are defined for them - in as , , - and for ints, - floats, doubless and s respectively. - - * @see matrix_example */ -//@{ -template -class EST_TVector -{ - // protected: -public: - /** Pointer to the start of the vector. - * The start of allocated memory is p_memory-p_offset. - */ - T *p_memory; - - /// Visible shape - unsigned int p_num_columns; - - /// How to access the memory - unsigned int p_offset; - unsigned int p_column_step; - - bool p_sub_matrix; - - - /// The memory access rule, in one place for easy reference - INLINE unsigned int vcell_pos(unsigned int c, - unsigned int cs) const - {return cs==1?c:c*cs;} - - INLINE unsigned int vcell_pos(unsigned int c) const - { - return vcell_pos(c, - p_column_step); - } - - INLINE unsigned int vcell_pos_1(unsigned int c) const - { - return c; - } - - /// quick method for returning \(x[n]\) - INLINE const T &fast_a_v(int c) const { return p_memory[vcell_pos(c)]; } - - INLINE T &fast_a_v(int c) { return p_memory[vcell_pos(c)]; } - - INLINE const T &fast_a_1(int c) const { return p_memory[vcell_pos_1(c)]; } - INLINE T &fast_a_1(int c) { return p_memory[vcell_pos_1(c)]; } - - /// Get and set values from array - void set_values(const T *data, int step, int start_c, int num_c); - void get_values(T *data, int step, int start_c, int num_c) const; - - /// private copy function, called from all other copying functions. - void copy(const EST_TVector &a); - /// just copy data, no resizing, no size check. - void copy_data(const EST_TVector &a); - - /// resize the memory and reset the bounds, but don't set values. - void just_resize(int new_cols, T** old_vals); - - /// sets data and length to default values (0 in both cases). - void default_vals(); - -public: - ///default constructor - EST_TVector(); - - /// copy constructor - EST_TVector(const EST_TVector &v); - - /// "size" constructor - make vector of size n. - EST_TVector(int n); - - /// construct from memory supplied by caller - EST_TVector(int, - T *memory, int offset=0, int free_when_destroyed=0); - - /// destructor. - ~EST_TVector(); - - /// default value, used for filling matrix after resizing - static const T *def_val; - - /** A reference to this variable is returned if you try and access - * beyond the bounds of the matrix. The value is undefined, but you - * can check for the reference you get having the same address as - * this variable to test for an error. - */ - static T *error_return; - - /** resize vector. If set=1, then the current values in - the vector are preserved up to the new length n. If the - new length exceeds the old length, the rest of the vector is - filled with the def_val - */ - void resize(int n, int set=1); - - /** For when you absolutely have to have access to the memory. - */ - const T * memory() const { return p_memory; } - T * memory(){ return p_memory; } - - /**@name access - * Basic access methods for vectors. - */ - //@{ - - /// number of items in vector. - INLINE int num_columns() const {return p_num_columns;} - /// number of items in vector. - INLINE int length() const {return num_columns();} - /// number of items in vector. - INLINE int n() const {return num_columns();} - - /// read-only const access operator: without bounds checking - INLINE const T &a_no_check(int n) const { return fast_a_v_x(n); } - /// read/write non-const access operator: without bounds checking - INLINE T &a_no_check(int n) { return fast_a_v_x(n); } - /// read-only const access operator: without bounds checking - INLINE const T &a_no_check_1(int n) const { return fast_a_1(n); } - /// read/write non-const access operator: without bounds checking - INLINE T &a_no_check_1(int n) { return fast_a_1(n); } - - // #define pp_a_no_check(V,N) (pp_fast_a(V,N)) - - /// read-only const access operator: with bounds checking - const T &a_check(int n) const; - /// read/write non-const access operator: with bounds checking - T &a_check(int n); - - const T &a(int n) const { return A_CHECK(n); } - T &a(int n) { return A_CHECK(n); } - - /// read-only const access operator: return reference to nth member - const T &operator () (int n) const {return A_CHECK(n);} - - // PT - // /// non const access operator: return reference to nth member - // T &operator () (int n) const {return a(n);} - - /// read/write non const access operator: return reference to nth member - T &operator [] (int n) { return A_CHECK(n); } - - //@} - - void set_memory(T *buffer, int offset, int columns, - int free_when_destroyed=0); - - /// assignment operator - EST_TVector &operator=(const EST_TVector &s); - - /// Fill entire array will value v. - void fill(const T &v); - - /// Fill vector with default value - void empty() { fill(*def_val); } - - /// is true if vectors are equal size and all elements are equal. - int operator == (const EST_TVector &v) const; - /// is true if vectors are not equal size or a single elements isn't equal. - int operator != (const EST_TVector &v) const - { return ! ((*this) == v); } - - /// Copy data in and out. Subclassed by SimpleVector for speed. - - void copy_section(T* dest, int offset=0, int num=-1) const; - void set_section(const T* src, int offset=0, int num=-1); - - /// Create a sub vector. - void sub_vector(EST_TVector &sv, int start_c=0, int len=-1); - /// print out vector. - friend ostream& operator << (ostream &st, const EST_TVector &m); - - /// Matrix must be friend to set up subvectors - friend class EST_TMatrix; - - void integrity() const; - -}; - -//@} -/// assignment operator: fill track with values in list s. -template -extern EST_TVector &set(EST_TVector &v, const EST_TList &s); - -template -extern ostream& operator << (ostream &st, const EST_TVector< T > &a); - -#undef A_CHECK -#endif diff --git a/src/est/EST_TVectorI.h b/src/est/EST_TVectorI.h deleted file mode 100644 index 5a68ec2ce2..0000000000 --- a/src/est/EST_TVectorI.h +++ /dev/null @@ -1,87 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - - -#ifndef __EST_TVECTOR_I_H__ -#define __EST_TVECTOR_I_H__ - -/** Instantiate rules for vector template. - * - * @author Richard Caley - * @version $Id: EST_TVectorI.h,v 1.3 2004/05/04 00:00:17 awb Exp $ - */ - - - - -// Instantiation Macros - -#define Instantiate_TVector_T_MIN(TYPE,TAG) \ - template class EST_TVector< TYPE >; - -#define Instantiate_TVector_T(TYPE,TAG) \ - Instantiate_TVector_T_MIN(TYPE,TAG) \ - \ - ostream& operator << (ostream &st, const EST_TVector< TYPE > &a) \ - {int i; for (i = 0; i < a.n(); ++i) st << a(i) << " "; st << endl; return st;} - - -#define Instantiate_TVector(TYPE) Instantiate_TVector_T(TYPE,TYPE) - -#define Declare_TVector_T(TYPE,TAG) \ - static TYPE const TAG##_vec_def_val_s; \ - static TYPE TAG##_vec_error_return_s; \ - \ - template <> TYPE const *EST_TVector< TYPE >::def_val=&TAG##_vec_def_val_s; \ - template <> TYPE *EST_TVector< TYPE >::error_return=&TAG##_vec_error_return_s; - -#define Declare_TVector_Base_T(TYPE,DEFAULT,ERROR,TAG) \ - static TYPE const TAG##_vec_def_val_s=DEFAULT; \ - static TYPE TAG##_vec_error_return_s=ERROR; \ - \ - template <> TYPE const *EST_TVector::def_val=&TAG##_vec_def_val_s; \ - template <> TYPE *EST_TVector::error_return=&TAG##_vec_error_return_s; - -#define Declare_TVector_Class_T(TYPE,DEFAULT,ERROR,TAG) \ - static TYPE const TAG##_vec_def_val_s(DEFAULT); \ - static TYPE TAG##_vec_error_return_s(ERROR); \ - \ - template <> TYPE const *EST_TVector::def_val=&TAG##_vec_def_val_s; \ - template <> TYPE *EST_TVector::error_return=&TAG##_vec_error_return_s; - -#define Declare_TVector(TYPE) Declare_TVector_T(TYPE,TYPE) -#define Declare_TVector_Base(TYPE,DEFAULT,ERROR) Declare_TVector_Base_T(TYPE,DEFAULT,ERROR,TYPE) -#define Declare_TVector_Class(TYPE,DEFAULT,ERROR) Declare_TVector_Class_T(TYPE,DEFAULT,ERROR,TYPE) - -#endif - diff --git a/src/est/EST_Token.h b/src/est/EST_Token.h deleted file mode 100644 index c51e1dc96a..0000000000 --- a/src/est/EST_Token.h +++ /dev/null @@ -1,390 +0,0 @@ -/*************************************************************************/ -/* */ -/* Centre for Speech Technology Research */ -/* University of Edinburgh, UK */ -/* Copyright (c) 1996 */ -/* All Rights Reserved. */ -/* */ -/* Permission is hereby granted, free of charge, to use and distribute */ -/* this software and its documentation without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of this work, and to */ -/* permit persons to whom this work is furnished to do so, subject to */ -/* the following conditions: */ -/* 1. The code must retain the above copyright notice, this list of */ -/* conditions and the following disclaimer. */ -/* 2. Any modifications must be clearly marked as such. */ -/* 3. Original authors' names are not deleted. */ -/* 4. The authors' names are not used to endorse or promote products */ -/* derived from this software without specific prior written */ -/* permission. */ -/* */ -/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ -/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ -/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ -/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ -/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ -/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ -/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ -/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ -/* THIS SOFTWARE. */ -/* */ -/*************************************************************************/ -/* Author : Alan W Black */ -/* Date : April 1996 */ -/*-----------------------------------------------------------------------*/ -/* Token/Tokenizer class */ -/* */ -/*=======================================================================*/ - -#ifndef __EST_TOKEN_H__ -#define __EST_TOKEN_H__ - -#include -#include "EST_String.h" -#include "EST_common.h" - -// I can never really remember this so we'll define it here -/// The default whitespace characters -extern const EST_String EST_Token_Default_WhiteSpaceChars; -/// -extern const EST_String EST_Token_Default_SingleCharSymbols; -/// -extern const EST_String EST_Token_Default_PunctuationSymbols; -/// -extern const EST_String EST_Token_Default_PrePunctuationSymbols; - -/** This class is similar to \Ref{EST_String} but also maintains - the original punctuation and whitespace found around the - token. - - \Ref{EST_Token}'s primary use is with \Ref{EST_TokenStream} class - which allows easy tokenizing of ascii files. - - A token consists of four parts, any of which may be empty: a - name, the actual token, preceding whitespace, preceding - punctuation, the name and succeeding punctuation. - - @author Alan W Black (awb@cstr.ed.ac.uk): April 1996 -*/ -class EST_Token { - private: - EST_String space; - EST_String prepunc; - EST_String pname; - EST_String punc; - int linenum; - int linepos; - int p_filepos; - int p_quoted; - - public: - /// - EST_Token() {init();} - /// - EST_Token(const EST_String p) {init(); pname = p; } - /// - void init() {p_quoted=linenum=linepos=p_filepos=0;} - - /**@name Basic access to fields */ - //@{ - /// set token from a string - void set_token(const EST_String &p) { pname = p; } - /// - void set_token(const char *p) { pname = p; } - /// set whitespace of token. - void set_whitespace(const EST_String &p) { space = p; } - /// - void set_whitespace(const char *p) { space = p; } - /// set (post) punctuation of token. - void set_punctuation(const EST_String &p) { punc = p; } - /// - void set_punctuation(const char *p) { punc = p; } - /// set prepunction - void set_prepunctuation(const EST_String &p) { prepunc = p; } - /// - void set_prepunctuation(const char *p) { prepunc = p; } - /// - const EST_String &whitespace() { return space; } - /// - const EST_String &punctuation() { return punc; } - /// - const EST_String &prepunctuation() { return prepunc; } - - /**@name Access token as a string */ - //@{ - const EST_String &string() const { return String(); } - /// Access token as a string - const EST_String &S() const { return S(); } - /// Access token as a string - const EST_String &String() const { return pname; } - /// For automatic coercion to \Ref{EST_String} - operator EST_String() const { return String(); } - //@} - - /**@name Access token as a int */ - //@{ - int Int(bool &valid) const { return String().Int(valid); } - int Int() const { return String().Int(); } - int I(bool &valid) const { return Int(valid); } - int I() const { return Int(); } - operator int() const { return Int(); } - //@} - - /**@name Access token as a long */ - //@{ - long Long(bool &valid) const { return String().Long(valid); } - long Long() const { return String().Long(); } - long L(bool &valid) const { return Long(valid); } - long L() const { return Long(); } - operator long() const { return Long(); } - //@} - - /**@name Access token as a float */ - //@{ - float Float(bool &valid) const { return String().Float(valid); } - float Float() const { return String().Float(); } - float F(bool &valid) const { return Float(valid); } - float F() const { return Float(); } - operator float() const { return Float(); } - //@} - - /**@name Access token as a double */ - //@{ - double Double(bool &valid) const { return String().Double(valid); } - double Double() const { return String().Double(); } - double D(bool &valid) const { return Double(valid); } - double D() const { return Double(); } - operator double() const { return Double(); } - //@} - - //@} - //@{ - /// Note that this token was quoted (or not) - void set_quoted(int q) { p_quoted = q; } - /// TRUE is token was quoted - int quoted() const { return p_quoted; } - //@} - /// - void set_row(int r) { linenum = r; } - /// - void set_col(int c) { linepos = c; } - /// Set file position in original \Ref{EST_TokenStream} - void set_filepos(int c) { p_filepos = c; } - /// Return lower case version of token name - EST_String lstring() { return downcase(pname); } - /// Return upper case version of token name - EST_String ustring() { return upcase(pname); } - /// Line number in original \Ref{EST_TokenStream}. - int row(void) const { return linenum; } - /// Line position in original \Ref{EST_TokenStream}. - int col(void) const { return linepos; } - /// file position in original \Ref{EST_TokenStream}. - int filepos(void) const { return p_filepos; } - - /// A string describing current position, suitable for error messages - const EST_String pos_description() const; - - /// - friend ostream& operator << (ostream& s, const EST_Token &p); - - /// - EST_Token & operator = (const EST_Token &a); - /// - EST_Token & operator = (const EST_String &a); - /// - int operator == (const EST_String &a) { return (pname == a); } - /// - int operator != (const EST_String &a) { return (pname != a); } - /// - int operator == (const char *a) { return (strcmp(pname,a)==0); } - /// - int operator != (const char *a) { return (strcmp(pname,a)!=0); } -}; - -enum EST_tokenstream_type {tst_none, tst_file, tst_pipe, tst_string, tst_istream}; - -/** A class that allows the reading of \Ref{EST_Token}s from a file - stream, pipe or string. It automatically tokenizes a file based on - user definable whitespace and punctuation. - - The definitions of whitespace and punctuation are user definable. - Also support for single character symbols is included. Single - character symbols {\em always} are treated as individual tokens - irrespective of their white space context. Also a quote - mode can be used to read uqoted tokens. - - The setting of whitespace, pre and post punctuation, single character - symbols and quote mode must be down (immediately) after opening - the stream. - - There is no unget but peek provides look ahead of one token. - - Note there is an interesting issue about what to do about - the last whitespace in the file. Should it be ignored or should - it be attached to a token with a name string of length zero. - In unquoted mode the eof() will return TRUE if the next token name - is empty (the mythical last token). In quoted mode the last must - be returned so eof will not be raised. - - @author Alan W Black (awb@cstr.ed.ac.uk): April 1996 -*/ -class EST_TokenStream{ - private: - EST_tokenstream_type type; - EST_String WhiteSpaceChars; - EST_String SingleCharSymbols; - EST_String PunctuationSymbols; - EST_String PrePunctuationSymbols; - EST_String Origin; - FILE *fp; - istream *is; - int fd; - char *buffer; - int buffer_length; - int pos; - int linepos; - int p_filepos; - int getch(void); - EST_TokenStream &getch(char &C); - int peeked_charp; - int peeked_char; // ungot character - int peekch(void); - int peeked_tokp; - int eof_flag; - int quotes; - char quote; - char escape; - EST_Token current_tok; - void default_values(void); - /* local buffers to save reallocating */ - int tok_wspacelen; - char *tok_wspace; - int tok_stufflen; - char *tok_stuff; - int tok_prepuncslen; - char *tok_prepuncs; - int close_at_end; - - /* character class map */ - char p_table[256]; - bool p_table_wrong; - - /** This function is deliberately private so that you'll get a compilation - error if you assign a token stream or pass it as an (non-reference) - argument. The problem with copying is that you need to copy the - filedescriptiors too (which can't be done for pipes). You probably - don't really want a copy anyway and meant to pass it as a reference. - If you really need this (some sort of clever look ahead) I am not - sure what he consequences really are (or how portable they are). - Pass the \Ref{EST_TokenStream} by reference instead. - */ - EST_TokenStream(EST_TokenStream &s); - - void build_table(); - - inline int getch_internal(); - inline int peekch_internal(); - inline int getpeeked_internal(); - public: - /// - EST_TokenStream(); - /// will close file if appropriate for type - ~EST_TokenStream(); - //@{ - /// open a \Ref{EST_TokenStream} for a file. - int open(const EST_String &filename); - /// open a \Ref{EST_TokenStream} for an already opened file - int open(FILE *ofp, int close_when_finished); - /// open a \Ref{EST_TokenStream} for an already open istream - int open(istream &newis); - /// open a \Ref{EST_TokenStream} for string rather than a file - int open_string(const EST_String &newbuffer); - /// Close stream. - void close(void); - //@} - /**@name stream access functions */ - //@{ - /// get next token in stream - EST_TokenStream &get(EST_Token &t); - /// get next token in stream - EST_Token &get(); - /**@name get the next token which must be the argument. */ - //@{ - EST_Token &must_get(EST_String expected, bool *ok); - EST_Token &must_get(EST_String expected, bool &ok) - { return must_get(expected, &ok); } - EST_Token &must_get(EST_String expected) - { return must_get(expected, (bool *)NULL); } - //@} - /// get up to {\tt s} in stream as a single token. - EST_Token get_upto(const EST_String &s); - /// get up to {\tt s} in end of line as a single token. - EST_Token get_upto_eoln(void); - /// peek at next token - EST_Token &peek(void) - { if (!peeked_tokp) get(); - peeked_tokp = TRUE; return current_tok; } - /// Reading binary data, (don't use peek() immediately beforehand) - int fread(void *buff,int size,int nitems); - //@} - /**@name stream initialization functions */ - //@{ - /// set which characters are to be treated as whitespace - void set_WhiteSpaceChars(const EST_String &ws) - { WhiteSpaceChars = ws; p_table_wrong=1;} - /// set which characters are to be treated as single character symbols - void set_SingleCharSymbols(const EST_String &sc) - { SingleCharSymbols = sc; p_table_wrong=1;} - /// set which characters are to be treated as (post) punctuation - void set_PunctuationSymbols(const EST_String &ps) - { PunctuationSymbols = ps; p_table_wrong=1;} - /// set which characters are to be treated as (post) punctuation - void set_PrePunctuationSymbols(const EST_String &ps) - { PrePunctuationSymbols = ps; p_table_wrong=1;} - /// set characters to be used as quotes and escape, and set quote mode - void set_quotes(char q, char e) { quotes = TRUE; quote = q; escape = e; p_table_wrong=1;} - /// query quote mode - int quoted_mode(void) { return quotes; } - //@} - /**@name miscellaneous */ - //@{ - /// returns line number of \Ref{EST_TokenStream} - int linenum(void) const {return linepos;} - /// end of file - int eof() - { return (eof_flag || ((!quotes) && (peek() == ""))); } - /// end of line - int eoln(); - /// current file position in \Ref{EST_TokenStream} - int filepos(void) const { return (type == tst_string) ? pos : p_filepos; } - /// tell, synonym for filepos - int tell(void) const { return filepos(); } - /// seek, reposition file pointer - int seek(int position); - int seek_end(); - /// Reset to start of file/string - int restart(void); - /// A string describing current position, suitable for error messages - const EST_String pos_description(); - /// The originating filename (if there is one) - const EST_String filename() const { return Origin; } - /// For the people who *need* the actual description (if possible) - FILE *filedescriptor() { return (type == tst_file) ? fp : 0; } - /// - EST_TokenStream & operator >>(EST_Token &p); - /// - EST_TokenStream & operator >>(EST_String &p); - /// - friend ostream& operator <<(ostream& s, EST_TokenStream &p); - //@} -}; - -/** Quote a string with given quotes and escape character -*/ -EST_String quote_string(const EST_String &s, - const EST_String "e = "\"", - const EST_String &escape = "\\", - int force=0); - -#endif // __EST_TOKEN_H__ diff --git a/src/est/EST_Track.h b/src/est/EST_Track.h deleted file mode 100644 index 5ab6a4241c..0000000000 --- a/src/est/EST_Track.h +++ /dev/null @@ -1,772 +0,0 @@ - /*************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1995,1996 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - /* */ - /* Author : Paul Taylor */ - /* Rewritten : Richard Caley */ - /* ------------------------------------------------------------------- */ - /* EST_Track Class header file */ - /* */ - /*************************************************************************/ - -class EST_Track; - -#ifndef __Track_H__ -#define __Track_H__ - -#include "EST_FMatrix.h" -#include "EST_types.h" -#include "EST_TrackMap.h" -#include "EST_ChannelType.h" -#include "EST_Featured.h" - -typedef EST_TMatrix EST_ValMatrix; - -class EST_TokenStream; -class EST_String; - -typedef enum EST_TrackFileType { - tff_none=0, - tff_ascii, - tff_esps, - tff_htk, - tff_htk_fbank, - tff_htk_mfcc, - tff_htk_user, - tff_htk_discrete, - tff_xmg, - tff_xgraph, - tff_ema, - tff_ema_swapped, - tff_NIST, - tff_est_ascii, - tff_est_binary, - tff_snns, - tff_ssff -} EST_TrackFileType; - -typedef enum EST_InterpType { - it_nearest, // nearest time point - it_linear, // linerar interpolation - it_linear_nz // .. unless one end near zero -} EST_InterpType; - -/** A class for storing time aligned coefficients. - -some stuff. -*/ - -class EST_Track : public EST_Featured { - -protected: - EST_FMatrix p_values; // float x array - EST_FVector p_times; // float y array - EST_CVector p_is_val; // for breaks and non-breaks - - EST_ValMatrix p_aux; // Auxiliary channels - EST_StrVector p_aux_names; // Names of auxiliary channels - - float p_t_offset; // time shift. - - EST_TrackMap::P p_map; - EST_StrVector p_channel_names; // name of each track - - bool p_equal_space; // fixed or variable frame rate - bool p_single_break; // single break lots between data - - void default_vals(); - void default_channel_names(); - void clear_arrays(); - void pad_breaks(); // put in extra breaks - - int interp_value(float x, float f); - float interp_amp(float x, int c, float f); - float estimate_shift(float x); - void copy(const EST_Track& a); - -public: - static const float default_frame_shift; - static const int default_sample_rate; - - /**@name Constructor and Destructor functions - */ - - //@{ - - /// Default constructor - EST_Track(); - - /// Copy constructor - EST_Track(const EST_Track &a); - - /// resizing constructor - EST_Track(int num_frames, int num_channels); - - /// resizing constructor - EST_Track(int num_frames, EST_StrList &map); - - /// default destructor - ~EST_Track(); - //@} - - /** @name Configuring Tracks - */ - //@{ - - /** resize the track to have {\tt num_frames} and {\tt num_channels}. - if {\tt preserve} is set to 1, any existing values in the track - are kept, up to the limits imposed by the new number of frames - and channels. If the new track size is bigger, new positions - are filled with 0 */ - void resize(int num_frames, int num_channels, bool preserve = 1); - - /** resize the track to have {\tt num_frames} and {\tt num_channels}. - if {\tt preserve} is set to 1, any existing values in the track - are kept, up to the limits imposed by the new number of frames - and channels. If the new track size is bigger, new positions - are filled with 0 */ - void resize(int num_frames, EST_StrList &map, bool preserve = 1); - - /** resize the track's auxiliary channels. - */ - void resize_aux(EST_StrList &map, bool preserve = 1); - - /** Change the number of channels while keeping the number of - frames the same. if {\tt preserve} is set to 1, any existing - values in the track are kept, up to the limits imposed by the - new number of frames and channels. If the new track size is - bigger, new positions are filled with 0 */ - void set_num_channels(int n, bool preserve = 1) - { resize(EST_CURRENT, n, preserve); } - - /** Change the number of frames while keeping the number of - channels the same. if {\tt preserve} is set to 1, any - existing values in the track are kept, up to the limits - imposed by the new number of frames and channels. If the new - track size is bigger, new positions are filled with 0 */ - void set_num_frames(int n, bool preserve = 1) - { resize(n, EST_CURRENT, preserve); } - - /// set the name of the channel. - void set_channel_name(const EST_String &name, int channel); - - /// set the name of the auxiliary channel. - void set_aux_channel_name(const EST_String &name, int channel); - - /// copy everything but data - - void copy_setup(const EST_Track& a); - //@} - - /**@name Global track information - */ - //@{ - /// name of track - redundant use access to features - EST_String name() const - { return f_String("name");} - /// set name of track - redundant use access to features - void set_name(const EST_String &n) - {f_set("name",n);} - - //@} - - /**@name Functions for sub tracks, channels and frames. - */ - //@{ - - /** make {\tt fv} a window to frame {\tt n} in the track. - */ - void frame(EST_FVector &fv, int n, int startf=0, int nf=EST_ALL) - { p_values.row(fv, n, startf, nf); } - - /** make {\tt fv} a window to channel {\tt n} in the track. - */ - void channel(EST_FVector &cv, int n, int startf=0, int nf=EST_ALL) - { p_values.column(cv, n, startf, nf); } - - /** make {\tt fv} a window to the named channel in the track. - */ - void channel(EST_FVector &cv, const char * name, int startf=0, - int nf=EST_ALL); - - /** make {\tt st} refer to a portion of the track. No values - are copied - an internal pointer in st is set to the specified - portion of the the track. After this, st behaves like a normal - track. Its first channel is the same as start_channel and its - first frame is the same as start_frame. Any values written into - st will changes values in the main track. st cannot be resized. - - @param start_frame first frame at which sub-track starts - @param nframes number of frames to be included in total - @param start_channel first channel at which sub-track starts - @param nframes number of channels to be included in total - */ - void sub_track(EST_Track &st, - int start_frame=0, int nframes=EST_ALL, - int start_chan=0, int nchans=EST_ALL); - - /** make {\tt st} refer to a portion of the track. No values - are copied - an internal pointer in st is set to the specified - portion of the the track. After this, st behaves like a normal - track. Its first channel is the same as start_channel and its - first frame is the same as start_frame. Any values written into - st will changes values in the main track. st cannot be resized. - - @param start_frame first frame at which sub-track starts - @param nframes number of frames to be included in total - @param start_channel_name name of channel at which sub-track starts - @param end_channel_name name of channel at which sub-track stops - */ - void sub_track(EST_Track &st, - int start_frame, int nframes, - const EST_String &start_chan_name, - int nchans=EST_ALL); - - /** make {\tt st} refer to a portion of the track. No values - are copied - an internal pointer in st is set to the specified - portion of the the track. After this, st behaves like a normal - track. Its first channel is the same as start_channel and its - first frame is the same as start_frame. Any values written into - st will changes values in the main track. st cannot be resized. - - @param start_frame first frame at which sub-track starts - @param nframes number of frames to be included in total - @param start_channel_name name of channel at which sub-track starts - @param end_channel_name name of channel at which sub-track stops - */ - void sub_track(EST_Track &st, - int start_frame, int nframes, - const EST_String &start_chan_name, - const EST_String &end_chan_name); - - /** make {\tt st} refer to a portion of the track. (const version) - No values - are copied - an internal pointer in st is set to the specified - portion of the the track. After this, st behaves like a normal - track. Its first channel is the same as start_channel and its - first frame is the same as start_frame. Any values written into - st will changes values in the main track. st cannot be resized. - - @param start_frame first frame at which sub-track starts - @param nframes number of frames to be included in total - @param start_channel first channel at which sub-track starts - @param nframes number of channels to be included in total - */ - void sub_track(EST_Track &st, - int start_frame=0, int nframes=EST_ALL, - int start_chan=0, int nchans=EST_ALL) const - { ((EST_Track *)this)->sub_track(st, start_frame, nframes, - start_chan, nchans); } - - /** Copy contiguous portion of track into {\tt st}. Unlike the - normal sub_track functions, this makes a completely new track. - values written into this will not affect the main track and it - can be resized. - - @param start_frame first frame at which sub-track starts - @param nframes number of frames to be included in total - @param start_channel first channel at which sub-track starts - @param nframes number of channels to be included in total - */ - - void copy_sub_track( EST_Track &st, - int start_frame=0, int nframes=EST_ALL, - int start_chan=0, int nchans=EST_ALL) const; - - void copy_sub_track_out( EST_Track &st, const EST_FVector& frame_times ) const; - void copy_sub_track_out( EST_Track &st, const EST_IVector& frame_indices ) const; - - /** copy channel {\tt n} into pre-allocated buffer buf */ - void copy_channel_out(int n, float *buf, int offset=0, int num=EST_ALL) - const - { p_values.copy_column(n, buf, offset, num); } - - /** copy channel {\tt n} into EST_FVector */ - void copy_channel_out(int n, EST_FVector &f, int offset=0, int num=EST_ALL) - const - { p_values.copy_column(n, f, offset, num); } - - /** copy frame {\tt n} into pre-allocated buffer buf */ - void copy_frame_out(int n, float *buf, int offset=0, int num=EST_ALL) - const {p_values.copy_row(n, buf, offset, num); } - - /** copy frame {\tt n} into EST_FVector */ - void copy_frame_out(int n, EST_FVector &f, int offset=0, int num=EST_ALL) - const {p_values.copy_row(n, f, offset, num); } - - /** copy buf into pre-allocated channel n of track */ - void copy_channel_in(int n, const float *buf, int offset=0, - int num=EST_ALL) - { p_values.set_column(n, buf, offset, num); } - - /** copy f into pre-allocated channel n of track */ - void copy_channel_in(int n, const EST_FVector &f, int offset=0, - int num=EST_ALL) - { p_values.set_column(n, f, offset, num); } - - /** copy channel buf into pre-allocated channel n of track */ - void copy_channel_in(int c, - const EST_Track &from, int from_c, int from_offset=0, - int offset=0, int num=EST_ALL) - { p_values.set_column(c, from.p_values, from_c, - from_offset, offset, num); } - - /** copy buf into frame n of track */ - void copy_frame_in(int n, const float *buf, int offset=0, - int num=EST_ALL) - { p_values.set_row(n, buf, offset, num); } - - /** copy t into frame n of track */ - void copy_frame_in(int n, const EST_FVector &t, int offset=0, - int num=EST_ALL) - { p_values.set_row(n, t, offset, num); } - - /** copy from into frame n of track */ - void copy_frame_in(int i, - const EST_Track &from, int from_f, int from_offset=0, - int offset=0, int num=EST_ALL) - { p_values.set_row(i, from.p_values, from_f, from_offset, offset, - num); } - - //@} - - /**@name Channel information - */ - - //@{ - - /** Return the position of channel {\tt name} if it exists, - otherwise return -1. - */ - int channel_position(const char *name, int offset=0) const; - - /** Return the position of channel {\tt name} if it exists, - otherwise return -1. - */ - int channel_position(EST_String name, int offset=0) const - { return channel_position((const char *)name, offset); } - - - /** Returns true if the track has a channel named {\tt name}, - otherwise false. - */ - - bool has_channel(const char *name) const - { return channel_position(name) >=0; } - - /** Returns true if the track has a channel named {\tt name}, - otherwise false. - */ - bool has_channel(EST_String name) const - { return has_channel((const char *)name); } - - //@} - - /** @name Accessing amplitudes The following functions can be used - to access to amplitude of the track at certain points. Most of - these functions can be used for reading or writing to this - point, thus - - tr.a(10, 5) = 10.3; - - can be used to set the 10th frame of the 5th channel and - - cout << tr.a(10, 5); - - can be used to print the same information. Most of these functions - have a const equivalent for helping the compiler in - read only operations. - */ - - //@{ - - /** return amplitude of frame i, channel c.*/ - float &a(int i, int c=0); - float a(int i, int c=0) const; - - /** return amplitude of frame i, channel c with no bounds - checking. */ - float &a_no_check(int i, int c=0) { return p_values.a_no_check(i,c); } - float a_no_check(int i, int c=0) const {return p_values.a_no_check(i,c);} - - /** return amplitude of point i, in the channel named name plus - offset. If you have a track with say channels called F0 and - voicing, you can access the 45th frame's F0 as t.a(45, "F0"); - If there are 20 cepstral coefficients for each frame, the 5th can - be accessed as t.a(45, "cepstrum", 5); - */ - - float &a(int i, const char *name, int offset=0); - - float a(int i, const char *name, int offset=0) const - { return ((EST_Track *)this)->a(i, name, offset); } - float &a(int i, EST_String name, int offset=0) - { return a(i, (const char *)name, offset); } - float a(int i, EST_String name, int offset=0) const - { return ((EST_Track *)this)->a(i, (const char *)name, offset); } - - /** return amplitude of time t, channel c. This can be used for - reading or writing to this point. By default the nearest frame - to this time is used. If {\tt interp} is set to {\tt - it_linear}, linear interpolation is performed between the two - amplitudes of the two frames either side of the time point to - give an estimation of what the amplitude would have been at - time {\tt t}. If {\tt interp} is set to {\tt it_linear_nz}, - interpolation is as above, unless the time requested is off - the end of a portion of track in which case the nearest - amplitude is returned. - */ - float &a(float t, int c=0, EST_InterpType interp=it_nearest); - float a(float t, int c=0, EST_InterpType interp=it_nearest) const - { return ((EST_Track *)this)->a(t, c, interp); } - - - /** return amplitude of frame i, channel c. */ - float &operator() (int i, int c) { return a(i,c); } - /** return amplitude of frame i, channel 0. */ - float &operator() (int i) { return a(i,0); } - float operator() (int i, int c) const { return a(i,c); } - float operator() (int i) const { return a(i,0); } - - /** return amplitude of frame nearest time t, channel c. */ - float &operator() (float t, int c) {return a(t,c); } - /** return amplitude of frame nearest time t, channel 0. */ - float &operator() (float t) {return a(t,0); } - float operator() (float t, int c) const {return a(t,c); } - float operator() (float t) const {return a(t,0); } - - //@} - - /** @name Timing - - */ - - //@{ - - /// return time position of frame i - float &t(int i=0) { return p_times[i]; } - float t(int i=0) const { return p_times(i); } - - /// return time of frame i in milli-seconds. - float ms_t(int i) const { return p_times(i) * 1000.0; } - - /** set frame times to regular intervals of time {\tt t}. - The {\tt start} parameter specifies the integer multiple of {\tt t} at - which to start. For example, setting this to 0 will start at time - 0.0 (The default means the first time value = {\tt t} - */ - void fill_time( float t, int start=1 ); - - /** set frame times to regular intervals of time {\tt t}. - The {\tt start} parameter specifies the first time value. - */ - void fill_time( float t, float start ); - - /** fill time channel with times from another track - */ - void fill_time( const EST_Track &t ); - - /** fill all amplitudes with value {\tt v} */ - void fill(float v) { p_values.fill(v); } - - /** resample track at this frame shift, specified in seconds. - This can be used to change a variable frame spaced track into - a fixed frame track, or to change the spacing of an existing - evenly spaced track. - */ - void sample(float shift); - - /// REDO - void change_type(float nshift, bool single_break); - - /** return an estimation of the frame spacing in seconds. - This returns -1 if the track is not a fixed shift track */ - float shift() const; - /// return time of first value in track - float start() const; - /// return time of last value in track - float end() const; - //@} - - /** @name Auxiliary channels - - Auxiliary information is used to store information that goes - along with frames, but which are not amplitudes and hence - not appropriate for operations such as interpolation, - smoothing etc. The aux() array is an array of EST_Vals which - allows points to be int, float or a string. - - The following functions can be used to access to auxiliary - track information. Most of these functions can be used for - reading or writing to this point, thus - - tr.aux(10, "voicing") = 1; - - can be used to set the 10th frame of the "voicing" channel and - - cout << tr.a(10, "voicing"); - - can be used to print the same information. Most of these functions - have a const equivalent for helping the compiler in - read only operations. - - Auxiliary channels are usually accessed by name rather than - numerical index. The names are set using the set_aux_channel_names() - function. - */ - - //@{ - - EST_Val &aux(int i, int c); - EST_Val &aux(int i, int c) const; - - EST_Val &aux(int i, const char *name); - EST_Val aux(int i, const char *name) const - { return ((EST_Track *)this)->aux(i, name); } - - EST_Val &aux(int i, EST_String name) - { return aux(i, (const char *)name); } - - EST_Val aux(int i, EST_String name) const - { return ((EST_Track *)this)->aux(i, (const char *)name); } - - //@} - - /** @name File i/o functions - */ - - //@{ - - /** Load a file called {\tt name} into the track. - The load function attempts to - automatically determine which file type is being loaded from the - file's header. If no header is found, the function assumes the - file is ascii data, with a fixed frame shift, arranged with rows - representing frames and columns channels. In this case, the - frame shift must be specified as an argument to this function. - For those file formats which don't contain provision for specifying - an initial time (e.g. HTK, or ascii...), the {\tt startt} parameter - may be specified. - */ - EST_read_status load(const EST_String name, float ishift = 0.0, float startt = 0.0); - - /** Load character data from an already opened tokenstream {\tt ts} - into the track. - The load function attempts to - automatically determine which file type is being loaded from the - file's header. If no header is found, the function assumes the - file is ascii data, with a fixed frame shift, arranged with rows - representing frames and columns channels. In this case, the - frame shift must be specified as an argument to this function - For those file formats which don't contain provision for specifying - an initial time (e.g. HTK, or ascii...), the {\tt startt} parameter - may be specified. - */ - EST_read_status load(EST_TokenStream &ts, float ishift = 0.0, float startt = 0.0); - - /** Load a file called {\tt name} of format {\tt type} - into the track. If no header is found, the function assumes the - file is ascii data, with a fixed frame shift, arranged with rows - representing frames and columns channels. In this case, the - frame shift must be specified as an argument to this function - For those file formats which don't contain provision for specifying - an initial time (e.g. HTK, or ascii...), the {\tt startt} parameter - may be specified. - */ - EST_read_status load(const EST_String name, const EST_String type, - float ishift = 0.0, float startt = 0.0 ); - - /** Save the track to a file {\tt name} of format {\tt type}. */ - EST_write_status save(const EST_String name, - const EST_String EST_filetype = ""); - - /** Save the track to a already opened file pointer{\tt FP} - and write a file of format {\tt type}. */ - EST_write_status save(FILE *fp, - const EST_String EST_filetype = ""); - - //@} - - /** @name Utility functions */ - - //@{ - /// returns true if no values are set in the frame - int empty() const; - - /// set frame i to be a break - void set_break(int i); - /// set frame i to be a value - void set_value(int i); - /// return true if frame i is a value - int val(int i) const; - /// return true if frame i is a break - int track_break(int i) const { return (p_is_val(i)); } - - /** starting at frame i, return the frame index of the first - value frame before i. If frame i is a value, return i */ - int prev_non_break(int i) const; - - /** starting at frame i, return the frame index of the first - value frame after i. If frame i is a value, return i */ - int next_non_break(int i) const; - - /// return the frame index nearest time t - int index(float t) const; - - /// return the frame index before time t - int index_below(float x) const; - - /// return number of frames in track - int num_frames() const {return p_values.num_rows();} - - /// return number of frames in track - int length() const { return num_frames(); } - - /// return number of channels in track - int num_channels() const {return p_values.num_columns();} - - /// return number of auxiliary channels in track - int num_aux_channels() const {return p_aux.num_columns();} - - void add_trailing_breaks(); - void rm_trailing_breaks(); - /** If the contour has multiple break values between sections - containing values, reduce the break sections so that each has - a single break only. */ - void rm_excess_breaks(); - - /// return true if track has equal (i.e. fixed) frame spacing */ - bool equal_space() const {return p_equal_space;} - - /**return true if track has only single breaks between value sections */ - bool single_break() const {return p_single_break;} - - void set_equal_space(bool t) {p_equal_space = t;} - void set_single_break(bool t) {p_single_break = t;} - - - //@} - - - EST_Track& operator = (const EST_Track& a); - EST_Track& operator+=(const EST_Track &a); // add to existing track - EST_Track& operator|=(const EST_Track &a); // add to existing track in parallel - friend ostream& operator << (ostream& s, const EST_Track &tr); - - // Default constructor - EST_Track(int num_frames, EST_TrackMap &map); - - // assign a known description to a track - void assign_map(EST_TrackMap::P map); - void assign_map(EST_TrackMap &map) { assign_map(&map); } - - // create a description for an unknown track - void create_map(EST_ChannelNameMap &names); - void create_map(void) { create_map(EST_default_channel_names); } - - EST_TrackMap::P map() const { return p_map; } - - int channel_position(EST_ChannelType type, int offset=0) const; - - - - // return amplitude of point i, channel type c (plus offset) - float &a(int i, EST_ChannelType c, int offset=0); - float a(int i, EST_ChannelType c, int offset=0) const - { return ((EST_Track *)this)->a(i,c, offset); } - - // return amplitude at time t, channel type c - float &a(float t, EST_ChannelType c, EST_InterpType interp=it_nearest); - float a(float t, EST_ChannelType c, EST_InterpType interp=it_nearest) const - { return ((EST_Track *)this)->a(t, c, interp); } - - float &operator() (int i, EST_ChannelType c) { return a(i,c); } - float operator() (int i, EST_ChannelType c) const { return a(i,c); } - - float &t_offset() { return p_t_offset; } - float t_offset() const { return p_t_offset; } - - - EST_read_status load_channel_names(const EST_String name); - EST_write_status save_channel_names(const EST_String name); - - const EST_String channel_name(int channel, const EST_ChannelNameMap &map, int strings_override=1) const; - const EST_String channel_name(int channel, int strings_override=1) const - { return channel_name(channel, EST_default_channel_names, strings_override); } - - const EST_String aux_channel_name(int channel) const - { return p_aux_names(channel);} - - void resize(int num_frames, EST_TrackMap &map); - - EST_TrackFileType file_type() const {return (EST_TrackFileType)f_Int("file_type",0);} - - - void set_file_type(EST_TrackFileType t) {f_set("file_type", (int)t);} - - - bool has_channel(EST_ChannelType type) const - { int cp = channel_position(type); - return cp>=0; } - - // Frame iteration support - -protected: - class IPointer_f { - public: - EST_Track *frame; int i; - IPointer_f(); - IPointer_f(const IPointer_f &p); - ~IPointer_f(); - }; - - void point_to_first(IPointer_f &ip) const { ip.i = 0; } - void move_pointer_forwards(IPointer_f &ip) const { ip.i++; } - bool points_to_something(const IPointer_f &ip) const { return ip.i ; - friend class EST_TRwIterator< EST_Track, IPointer_f, EST_Track >; - -public: - typedef EST_Track Entry; - typedef EST_TIterator< EST_Track, IPointer_f, EST_Track > Entries; - typedef EST_TRwIterator< EST_Track, IPointer_f, EST_Track > RwEntries; - -}; - -// list of tracks in serial -typedef EST_TList EST_TrackList; - - -#endif /* __Track_H__ */ diff --git a/src/est/EST_TrackMap.h b/src/est/EST_TrackMap.h deleted file mode 100644 index 38967199d2..0000000000 --- a/src/est/EST_TrackMap.h +++ /dev/null @@ -1,176 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /************************************************************************/ - -#ifndef __EST_TRACKMAP_H__ -#define __EST_TRACKMAP_H__ - -#include -#include "EST_TNamedEnum.h" -#include "EST_ChannelType.h" -#include "EST_Handleable.h" -#include "EST_THandle.h" - -/** Track maps provide a mapping from symbolic track names to the - * actual position of the information within a track frame. The - * symbolic names are defined by the EST_ChannelType enumerated type. - * - * Track maps can be declared statically by code which always uses - * tracks of a given style, or they can be built at run time as - * is done by lpc_analysis to record whichinformation the - * user has requested. Finally they can be constructed by the Track - * itself from the names of the channels, for instance when a track has - * just been read in from a file. - * - * @see EST_Track - * @see EST_ChannelType - * @see EST_TrackMap:example - * @author Richard Caley - * @version $Id: EST_TrackMap.h,v 1.3 2004/05/04 00:00:16 awb Exp $ - */ -class EST_TrackMap : public EST_Handleable -{ - -public: - /**@name ChannelMapping - * An auxiliary type used just to define static EST_TrackMaps. - * Defining one of these and then converting it to an EST_TrackMap - * is, unfortunately, the only way C++ allows us to define - * a constant EST_TrackMap. - */ - //@{ - /// structure for the table. - struct ChannelMappingElement { - EST_ChannelType type; - unsigned short channel; - }; - /// Table of type to position pairs. -// typedef struct ChannelMappingElement ChannelMapping[]; - //@} - - typedef EST_THandle P; - -public: - - /// Returned if we ask for a channel not in the map. -# define NO_SUCH_CHANNEL (-1) - -private: - - /// The map itself. - short p_map[num_channel_types]; - - /// Parent is looked at if this map doesn't define the position. - EST_TrackMap::P p_parent; - /// Subtracted from the values in the parent. - int p_offset; - - /// No copy constructor. Don't copy these things. - EST_TrackMap(EST_TrackMap &from); - -protected: - /// Pass to creation function to turn on refcounting. -#define EST_TM_REFCOUNTED (1) - - /// Creation function used by friends to create refcounted maps. - EST_TrackMap(int refcount); - - /// Creation function used by friends to create sub-track maps. - EST_TrackMap(const EST_TrackMap *parent, int offset, int refcount); - - /// copy an exiting map. - void copy(EST_TrackMap &from); - /// Initialise the map. - void init(void); - - short get_parent(EST_ChannelType type) const ; - -public: - /// Default constructor. - EST_TrackMap(void); - /// Copy the mapping. - EST_TrackMap(EST_TrackMap &from, int refcount); - /// Create from static table. - EST_TrackMap(struct ChannelMappingElement map[]); - - - ~EST_TrackMap(); - - /// Empty the map. - void clear(void); - /// Record the position of a channel. - void set(EST_ChannelType type, short pos) - { p_map[(int)type] = pos; } - - /// Get the position of a channel. - short get(EST_ChannelType type) const - { short c = p_map[(int)type]; - return c!=NO_SUCH_CHANNEL?c:get_parent(type); } - /// Get the position of a channel. - short operator() (EST_ChannelType type) const - { return get(type); } - - /// Does the mapping contain a position for this channel? - bool has_channel(EST_ChannelType type) const - { return p_map[(int)type] != NO_SUCH_CHANNEL - || ( p_parent!=0 && p_parent->has_channel(type) ); } - - /// Returns the index of the last known channel. - short last_channel(void) const; - - /// Returns the type of the channel at the given position. - EST_ChannelType channel_type(unsigned short channel) const; - - EST_TrackMap * object_ptr() { return this; } - const EST_TrackMap * object_ptr() const { return this; } - - friend class EST_Track; - friend ostream& operator << (ostream &st, const EST_TrackMap &m); -}; - -/** Channel name maps map textual names for track channels to symbolic - * names, they are just a special case of named enums. - */ -typedef EST_TNamedEnum EST_ChannelNameMap; - -/** Table type used to create EST_ChannelNameMaps. - */ -typedef EST_TValuedEnumDefinition - EST_ChannelNameTable[]; - -/// Definition of standard names we use for channels. -extern EST_ChannelNameMap EST_default_channel_names; -/// Definition of the names ESPS programs use for channels. -extern EST_ChannelNameMap esps_channel_names; - -extern ostream& operator << (ostream &st, const EST_TrackMap &m); -#endif diff --git a/src/est/EST_UList.h b/src/est/EST_UList.h deleted file mode 100644 index aafca932ab..0000000000 --- a/src/est/EST_UList.h +++ /dev/null @@ -1,142 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - /* */ - /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */ - /* Date: Mon Jul 21 1997 */ - /* -------------------------------------------------------------------- */ - /* Untyped list used as the basis of the TList class */ - /* */ - /*************************************************************************/ - -#ifndef __EST_ULIST_H__ -#define __EST_ULIST_H__ - -#include -#include "EST_common.h" -#include "EST_String.h" - -class EST_UItem { -public: - void init() { n = NULL; p = NULL;} - EST_UItem *n; - EST_UItem *p; -}; - -class EST_UList { -protected: - EST_UItem *h; - EST_UItem *t; - -protected: - void init() { h = NULL; t = NULL; }; - void clear_and_free(void (*item_free)(EST_UItem *item)); - -public: - EST_UList() { init(); }; - ~ EST_UList() { clear_and_free(NULL); } - - EST_UItem *nth_pointer(int n) const; - - EST_UItem *insert_after(EST_UItem *ptr, EST_UItem *new_item); // returns pointer to inserted item - EST_UItem *insert_before(EST_UItem *ptr, EST_UItem *new_item); // returns pointer to item after inserted item - - // remove single item, return pointer to previous - EST_UItem *remove(EST_UItem *ptr, void (*item_free)(EST_UItem *item)); - EST_UItem *remove(int n, void (*item_free)(EST_UItem *item)); - - void exchange(EST_UItem *a, EST_UItem *b); - void exchange(int i, int j); - - void reverse(); // in place - - int length() const; // number of items in list - int index(EST_UItem *item) const; // position from start of list (head = 0) - - int empty() const // returns true if no items in list - {return (h == NULL) ? 1 : 0;}; - void clear(void) - { clear_and_free(NULL); }; - void append(EST_UItem *item); // add item onto end of list - - void prepend(EST_UItem *item); // add item onto start of list - - EST_UItem *head() const // return pointer to head of list - { return h; }; - EST_UItem *tail() const // return pointer to tail of list - { return t; }; - - - static bool operator_eq(const EST_UList &a, - const EST_UList &b, - bool (*eq)(const EST_UItem *item1, const EST_UItem *item2)); - - static int index(const EST_UList &l, - const EST_UItem &b, - bool (*eq)(const EST_UItem *item1, const EST_UItem *item2)); - - static void sort(EST_UList &a, - bool (*gt)(const EST_UItem *item1, const EST_UItem *item2)); - static void qsort(EST_UList &a, - bool (*gt)(const EST_UItem *item1, const EST_UItem *item2), - void (*exchange)(EST_UItem *item1, EST_UItem *item2)); - static void sort_unique(EST_UList &l, - bool (*eq)(const EST_UItem *item1, const EST_UItem *item2), - bool (*gt)(const EST_UItem *item1, const EST_UItem *item2), - void (*item_free)(EST_UItem *item)); - static void merge_sort_unique(EST_UList &l, EST_UList &m, - bool (*eq)(const EST_UItem *item1, const EST_UItem *item2), - bool (*gt)(const EST_UItem *item1, const EST_UItem *item2), - void (*item_free)(EST_UItem *item)); -}; - - -// inline functions in header file -// everything else in EST_UList.C - -inline EST_UItem *next(EST_UItem *ptr) -{ - if (ptr != 0) - return ptr->n; - return 0; -} - -inline EST_UItem *prev(EST_UItem *ptr) -{ - if (ptr != 0) - return ptr->p; - return 0; -} - - - -#endif diff --git a/src/est/EST_Val.h b/src/est/EST_Val.h deleted file mode 100644 index a01091da14..0000000000 --- a/src/est/EST_Val.h +++ /dev/null @@ -1,265 +0,0 @@ -/*************************************************************************/ -/* */ -/* Centre for Speech Technology Research */ -/* University of Edinburgh, UK */ -/* Copyright (c) 1995,1996 */ -/* All Rights Reserved. */ -/* */ -/* Permission is hereby granted, free of charge, to use and distribute */ -/* this software and its documentation without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of this work, and to */ -/* permit persons to whom this work is furnished to do so, subject to */ -/* the following conditions: */ -/* 1. The code must retain the above copyright notice, this list of */ -/* conditions and the following disclaimer. */ -/* 2. Any modifications must be clearly marked as such. */ -/* 3. Original authors' names are not deleted. */ -/* 4. The authors' names are not used to endorse or promote products */ -/* derived from this software without specific prior written */ -/* permission. */ -/* */ -/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ -/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ -/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ -/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ -/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ -/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ -/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ -/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ -/* THIS SOFTWARE. */ -/* */ -/*************************************************************************/ -/* Author : Alan W Black */ -/* Date : May 1996 */ -/*-----------------------------------------------------------------------*/ -/* */ -/* A generic container class, originally for ints floats and string now */ -/* extended for some others, eventually allow run addition of new types */ -/* "built-in" types (i.e. ones explicitly mentioned in this file) may */ -/* be accessed by member functions, objects added at run time may only */ -/* be accessed by functions */ -/* */ -/* This is so similar to the LISP class in SIOD it could be viewed as a */ -/* little embarrassing, but this is done without a cons cell heap or gc */ -/* which may or may not be a good thing. */ -/* */ -/*=======================================================================*/ -#ifndef __EST_VAL_H__ -#define __EST_VAL_H__ - -#include "EST_String.h" -//#include "EST_error.h" -#include "EST_Contents.h" -#include "EST_Val_defs.h" - -typedef const char *val_type; - -extern val_type val_unset; -extern val_type val_int; -extern val_type val_float; -extern val_type val_string; - -/** The EST_Val class is a container class, used to store a single - item which can be an int, float, string or other user-defined - class. It is often used as the base item in the EST_Features class, to enable features - to take on values of different types. -*/ - -class EST_Val { - private: - val_type t; - union - { int ival; - float fval; - EST_Contents *pval;} v; - // * may have a string name as well as a value - EST_String sval; - const int to_int() const; - const float to_flt() const; - const EST_String &to_str() const; - public: - /**@name Constructor and Destructor functions - */ - - //@{ - /** Default constructor */ - EST_Val() - {t=val_unset;} - - /** Copy constructor for another EST_Val*/ - EST_Val(const EST_Val &val); - - /** Copy constructor for an int*/ - EST_Val(const int i) - {t=val_int; v.ival=i;} - - /** Copy constructor for a float*/ - EST_Val(const float f) - {t=val_float; v.fval=f;} - - /** Copy constructor for a double*/ - EST_Val(const double d) {t=val_float; v.fval=d;} - - /** Copy constructor for a string*/ - // EST_Val(const EST_String &s) {t=val_string; sval = s;} - EST_Val(const EST_String &s) : t(val_string), sval(s) {}; - - /** Copy constructor for a string literal*/ - // EST_Val(const char *s) {t=val_string; sval = s;} - EST_Val(const char *s) : t(val_string), sval(s) {}; - - EST_Val(val_type type,void *p, void (*f)(void *)); - - /** Destructor */ - ~EST_Val(void); - - //@} - - /**@name Getting cast values - */ - - //@{ - - /** returns the type that the val is currently holding */ - const val_type type(void) const - {return t;} - - /** returns the value, cast as an int */ - const int Int(void) const - {if (t==val_int) return v.ival; return to_int();} - - /** returns the value, cast as an int */ - const int I(void) const - { return Int(); } - - /** returns the value, cast as a float */ - const float Float(void) const - {if (t==val_float) return v.fval; return to_flt();} - - /** returns the value, cast as a float */ - const float F(void) const - { return Float(); } - - /** returns the value, cast as a string */ - const EST_String &String(void) const - {if (t!=val_string) to_str(); return sval;} - - /** returns the value, cast as a string */ - const EST_String &string(void) const - {return String();} - - /** returns the value, cast as a string */ - const EST_String &S(void) const - {return String();} - - /** returns the value, cast as a string */ - const EST_String &string_only(void) const {return sval;} - - //@} - - // Humans should never call this only automatic functions - const void *internal_ptr(void) const - { return v.pval->get_contents(); } - - /**@name Setting values - */ - - //@{ - - /** Assignment of val to an int */ - EST_Val &operator=(const int i) { t=val_int; v.ival=i; return *this;} - - /** Assignment of val to a float */ - EST_Val &operator=(const float f) { t=val_float; v.fval=f; return *this;} - - /** Assignment of val to a double */ - EST_Val &operator=(const double d) { t=val_float; v.fval=d; return *this;} - - /** Assignment of val to a string */ - EST_Val &operator=(const EST_String &s) { t=val_string; sval = s; return *this;} - - /** Assignment of val to a string literal*/ - EST_Val &operator=(const char *s) { t=val_string; sval = s; return *this;} - - /** Assignment of val to another val*/ - EST_Val &operator=(const EST_Val &c); - - //@} - - /**@name Equivalence test - */ - - //@{ - - - /** Test whether val is equal to a*/ - int operator ==(const EST_Val &a) const - { if (t != a.t) return (1==0); - else if (t == val_string) return (sval == a.sval); - else if (t == val_int) return (v.ival == a.v.ival); - else if (t == val_float) return (v.fval == a.v.fval); - else return (internal_ptr() == a.internal_ptr()); } - - /** Test whether val is equal to the string a*/ - int operator ==(const EST_String &a) const { return (string() == a); } - /** Test whether val is equal to the char * a*/ - int operator ==(const char *a) const { return (string() == a); } - /** Test whether val is equal to the int a*/ - int operator ==(const int &i) const { return (Int() == i); } - /** Test whether val is equal to the float a*/ - int operator ==(const float &f) const { return (Float() == f); } - /** Test whether val is equal to the double a*/ - int operator ==(const double &d) const { return (Float() == d); } - - - /** Test whether val is not equal to the val a*/ - int operator !=(const EST_Val &a) const { return (!(*this == a)); } - /** Test whether val is not equal to the string a*/ - int operator !=(const EST_String &a) const { return (string() != a); } - /** Test whether val is not equal to the char * a*/ - int operator !=(const char *a) const { return (string() != a); } - /** Test whether val is not equal to the int a*/ - int operator !=(const int &i) const { return (Int() != i);} - /** Test whether val is not equal to the float a*/ - int operator !=(const float &f) const { return (Float() != f); } - /** Test whether val is not equal to the double float a*/ - int operator !=(const double &d) const { return (Float() != d); } - - //@{ - - /**@name Automatic casting - */ - //@{ - - /** Automatically cast val as an int*/ - operator int() const { return Int(); } - /** Automatically cast val as an float*/ - operator float() const { return Float(); } - /** Automatically cast val as an string*/ - operator EST_String() const { return string(); } - //@} - /** print val*/ - friend ostream& operator << (ostream &s, const EST_Val &a) - { if (a.type() == val_unset) s << "[VAL unset]" ; - else if (a.type() == val_int) s << a.v.ival; - else if (a.type() == val_float) s << a.v.fval; - else if (a.type() == val_string) s << a.sval; - else s << "[PVAL " << a.type() << "]"; - return s; - } -}; - -inline const char *error_name(const EST_Val val) { return (EST_String)val;} - -// For consistency with other (user-defined) types in val -inline EST_String string(const EST_Val &v) { return v.string(); } -inline EST_Val est_val(const EST_String s) { return EST_Val(s); } -inline EST_Val est_val(const char *s) { return EST_Val(s); } -inline int Int(const EST_Val &v) { return v.Int(); } -inline EST_Val est_val(const int i) { return EST_Val(i); } -inline float Float(const EST_Val &v) { return v.Float(); } -inline EST_Val est_val(const float f) { return EST_Val(f); } - -#endif diff --git a/src/est/EST_Val_defs.h b/src/est/EST_Val_defs.h deleted file mode 100644 index 32858c9674..0000000000 --- a/src/est/EST_Val_defs.h +++ /dev/null @@ -1,180 +0,0 @@ -/*************************************************************************/ -/* */ -/* Centre for Speech Technology Research */ -/* University of Edinburgh, UK */ -/* Copyright (c) 1999 */ -/* All Rights Reserved. */ -/* */ -/* Permission is hereby granted, free of charge, to use and distribute */ -/* this software and its documentation without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of this work, and to */ -/* permit persons to whom this work is furnished to do so, subject to */ -/* the following conditions: */ -/* 1. The code must retain the above copyright notice, this list of */ -/* conditions and the following disclaimer. */ -/* 2. Any modifications must be clearly marked as such. */ -/* 3. Original authors' names are not deleted. */ -/* 4. The authors' names are not used to endorse or promote products */ -/* derived from this software without specific prior written */ -/* permission. */ -/* */ -/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ -/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ -/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ -/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ -/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ -/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ -/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ -/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ -/* THIS SOFTWARE. */ -/* */ -/*************************************************************************/ -/* Author : Alan W Black */ -/* Date : March 1999 */ -/*-----------------------------------------------------------------------*/ -/* */ -/* Macros definitions for defining anything as vals */ -/* */ -/*=======================================================================*/ -#ifndef __EST_VAL_DEFS_H__ -#define __EST_VAL_DEFS_H__ - -/* Macro for defining new class as values public functions */ -#define VAL_REGISTER_CLASS_DCLS(NAME,CLASS) \ -extern val_type val_type_##NAME; \ -class CLASS *NAME(const EST_Val &v); \ -EST_Val est_val(const class CLASS *v); - -/* For things that aren't classes (typed def something else) */ -#define VAL_REGISTER_TYPE_DCLS(NAME,CLASS) \ -extern val_type val_type_##NAME; \ -CLASS *NAME(const EST_Val &v); \ -EST_Val est_val(const CLASS *v); - -#define VAL_REGISTER_FUNCPTR_DCLS(NAME,TYPE) \ -extern val_type val_type_##NAME; \ -TYPE NAME(const EST_Val &v); \ -EST_Val est_val(const TYPE v); - - -/* Macro for defining new class as values */ -#define VAL_REGISTER_CLASS(NAME,CLASS) \ -val_type val_type_##NAME=#NAME; \ -class CLASS *NAME(const EST_Val &v) \ -{ \ - if (v.type() == val_type_##NAME) \ - return (class CLASS *)v.internal_ptr(); \ - else \ - EST_error("val not of type val_type_"#NAME); \ - return NULL; \ -} \ - \ -static void val_delete_##NAME(void *v) \ -{ \ - delete (class CLASS *)v; \ -} \ - \ -EST_Val est_val(const class CLASS *v) \ -{ \ - return EST_Val(val_type_##NAME, \ - (void *)v,val_delete_##NAME); \ -} \ - -/* Macro for defining new typedef'd things as vals */ -/* You don't need CLASS and TYPE but it often convenient */ -#define VAL_REGISTER_TYPE(NAME,CLASS) \ -val_type val_type_##NAME=#NAME; \ -CLASS *NAME(const EST_Val &v) \ -{ \ - if (v.type() == val_type_##NAME) \ - return (CLASS *)v.internal_ptr(); \ - else \ - EST_error("val not of type val_type_"#NAME); \ - return NULL; \ -} \ - \ -static void val_delete_##NAME(void *v) \ -{ \ - delete (CLASS *)v; \ -} \ - \ -EST_Val est_val(const CLASS *v) \ -{ \ - return EST_Val(val_type_##NAME, \ - (void *)v,val_delete_##NAME); \ -} \ - -/* Macro for defining new typedef'd things as vals that don't get deleted */ -/* You don't need CLASS and TYPE but it often convenient */ -#define VAL_REGISTER_TYPE_NODEL(NAME,CLASS) \ -val_type val_type_##NAME=#NAME; \ -CLASS *NAME(const EST_Val &v) \ -{ \ - if (v.type() == val_type_##NAME) \ - return (CLASS *)v.internal_ptr(); \ - else \ - EST_error("val not of type val_type_"#NAME); \ - return NULL; \ -} \ - \ -static void val_delete_##NAME(void *v) \ -{ \ - (void)v; \ -} \ - \ -EST_Val est_val(const CLASS *v) \ -{ \ - return EST_Val(val_type_##NAME, \ - (void *)v,val_delete_##NAME); \ -} \ - -/* Macro for defining new class as values */ -#define VAL_REGISTER_CLASS_NODEL(NAME,CLASS) \ -val_type val_type_##NAME=#NAME; \ -class CLASS *NAME(const EST_Val &v) \ -{ \ - if (v.type() == val_type_##NAME) \ - return (class CLASS *)v.internal_ptr(); \ - else \ - EST_error("val not of type val_type_"#NAME); \ - return NULL; \ -} \ - \ -static void val_delete_##NAME(void *v) \ -{ \ - (void)v; \ -} \ - \ -EST_Val est_val(const class CLASS *v) \ -{ \ - return EST_Val(val_type_##NAME, \ - (void *)v,val_delete_##NAME); \ -} \ - -/* Macro for defining function pointers as values */ -#define VAL_REGISTER_FUNCPTR(NAME,CLASS) \ -val_type val_type_##NAME=#NAME; \ -CLASS NAME(const EST_Val &v) \ -{ \ - if (v.type() == val_type_##NAME) \ - return (CLASS)v.internal_ptr(); \ - else \ - EST_error("val not of type val_type_"#NAME); \ - return NULL; \ -} \ - \ -static void val_delete_##NAME(void *v) \ -{ \ - (void)v; \ -} \ - \ -EST_Val est_val(const CLASS v) \ -{ \ - return EST_Val(val_type_##NAME, \ - (void *)v,val_delete_##NAME); \ -} \ - - - -#endif diff --git a/src/est/EST_Wave.h b/src/est/EST_Wave.h deleted file mode 100644 index 86177d3478..0000000000 --- a/src/est/EST_Wave.h +++ /dev/null @@ -1,323 +0,0 @@ - /*************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - /* */ - /* Author : Paul Taylor and Alan W Black */ - /* Rewritten : Richard Caley */ - /* ------------------------------------------------------------------- */ - /* EST_Wave Class header file */ - /* */ - /*************************************************************************/ - -#ifndef __Wave_H__ -#define __Wave_H__ - -#include -#include "EST_Featured.h" -#include "EST_rw_status.h" -#include "EST_types.h" - -class EST_Track; -class EST_String; -class EST_TokenStream; - - -/** A class for storing digital waveforms. The waveform is stored as -an array of 16 bit shorts. Multiple channels are supported, but if no -channel information is given the 0th channel is accessed. -

- -The waveforms can be of any sample rate, and can be changed to another -sampling rate using the resample function. - -*/ - -class EST_Wave : public EST_Featured -{ -protected: - EST_SMatrix p_values; - - int p_sample_rate; - - void default_vals(int n=0, int c=1); - void free_wave(); - void copy_data(const EST_Wave &w); - void copy_setup(const EST_Wave &w); - -public: - - static const int default_sample_rate; - static const int default_num_channels; - - /// default constructor - EST_Wave(); - /// copy constructor - EST_Wave(const EST_Wave &a); - - EST_Wave(int n, int c, int sr); - - /// Construct from memory supplied by caller - EST_Wave(int samps, int chans, - short *memory, int offset=0, int sample_rate=default_sample_rate, - int free_when_destroyed=0); - - ~EST_Wave(); - - - /**@name Access functions for finding amplitudes of samples */ - //@{ - - /** return amplitude of sample i from channel - channel. By default the 0th channel is selected. This - function can be used for assignment. - */ - short &a(int i, int channel = 0); - short a(int i, int channel = 0) const; - INLINE short &a_no_check(int i, int channel = 0) - { return p_values.a_no_check(i,channel); } - INLINE short a_no_check(int i, int channel = 0) const - { return p_values.a_no_check(i,channel); } - INLINE short &a_no_check_1(int i, int channel = 0) - { return p_values.a_no_check_1(i,channel); } - INLINE short a_no_check_1(int i, int channel = 0) const - { return p_values.a_no_check_1(i,channel); } - - /** return amplitude of sample i from channel - channel. By default the 0th channel is selected. - */ - short operator()(int i, int channel) const - { return a(i,channel); } - - /** return amplitude of sample i from channel 0. - */ - short operator()(int i) const - { return a(i,0); } - - /** Version of a() that returns zero if index is out of array - bounds. This is particularly useful in signal processing when - you want to have windows going off the end of the waveform. */ - short &a_safe(int i, int channel = 0); - - /// return the time position in seconds of the ith sample - float t(int i) const { return (float)i/(float)p_sample_rate; } - //@} - - /**@name Information functions */ - //@{ - /// return the number of samples in the waveform - int num_samples() const { return p_values.num_rows();} - /// return the number of channels in the waveform - int num_channels() const { return p_values.num_columns(); } - /// return the sampling rate (frequency) - int sample_rate() const { return p_sample_rate; } - /// Set sampling rate to n - void set_sample_rate(const int n){p_sample_rate = n;} - /// return the size of the waveform, i.e. the number of samples. - int length() const { return num_samples();} - /// return the time position of the last sample. - float end(){ return t(num_samples()-1); } - - /// Can we look N samples to the left? - bool have_left_context(unsigned int n) const - { return p_values.have_rows_before(n); } - - /** returns the file format of the file from which the waveform - was read. If the waveform has not been read from a file, this is set - to the default type */ - - EST_String sample_type() const { return f_String("sample_type","short"); } - void set_sample_type(const EST_String t) { f_set("sample_type", t); } - - EST_String file_type() const { return f_String("file_type","riff"); } - void set_file_type(const EST_String t) { f_set("file_type", t); } - - /// A string identifying the waveform, commonly used to store the filename - EST_String name() const { return f_String("name"); } - - /// Sets name. - void set_name(const EST_String n){ f_set("name", n); } - - //@} - - const EST_SMatrix &values() const { return p_values; } - EST_SMatrix &values() { return p_values; } - - /**@name Waveform manipulation functions */ - //@{ - - /// resize the waveform - void resize(int num_samples, int num_channels = EST_ALL, int set=1) - { p_values.resize(num_samples, num_channels, set); } - - /// Resample waveform to rate - void resample(int rate); - - /** multiply all samples by a factor gain. This checks for - overflows and puts them to the maximum positive or negative value - as appropriate. - */ - void rescale(float gain,int normalize=0); - - // multiply samples by a factor contour. The factor_contour track - // should contains factor targets at time points throughout the wave, - // between which linear interpolation is used to calculate the factor - // for each sample. - void rescale( const EST_Track &factor_contour ); - - /// clear waveform and set size to 0. - void clear() {resize(0,EST_ALL);} - - void copy(const EST_Wave &from); - - void fill(short v=0, int channel=EST_ALL); - - void empty(int channel=EST_ALL) { fill(0,channel); } - - void sample(EST_TVector &sv, int n) - { p_values.row(sv, n); } - void channel(EST_TVector &cv, int n) - { p_values.column(cv, n); } - - void copy_channel(int n, short *buf, int offset=0, int num=EST_ALL) const - { p_values.copy_column(n, buf, offset, num); } - void copy_sample(int n, short *buf, int offset=0, int num=EST_ALL) const - { p_values.copy_row(n, buf, offset, num); } - - void set_channel(int n, const short *buf, int offset=0, int num=EST_ALL) - { p_values.set_column(n, buf, offset, num); } - void set_sample(int n, const short *buf, int offset=0, int num=EST_ALL) - { p_values.set_row(n, buf, offset, num); } - - - void sub_wave(EST_Wave &sw, - int offset=0, int num=EST_ALL, - int start_c=0, int nchan=EST_ALL); - - void sub_wave(EST_Wave &sw, - int offset=0, int num=EST_ALL, - int start_c=0, int nchan=EST_ALL) const - { ((EST_Wave *)this)->sub_wave(sw, offset, num, start_c, nchan); } - - //@} - - /**@name File i/o functions */ - //@{ - - /** Load a file into the waveform. The load routine attempts to - automatically determine which file type is being loaded. A - portion of the waveform can be loaded by setting - offset to the sample position from the beginning and - to the number of required samples after this. */ - - EST_read_status load(const EST_String filename, - int offset=0, - int length = 0, - int rate = default_sample_rate); - - EST_read_status load(EST_TokenStream &ts, - int offset=0, - int length = 0, - int rate = default_sample_rate); - - EST_read_status load(const EST_String filename, - const EST_String filetype, - int offset=0, - int length = 0, - int rate = default_sample_rate); - - EST_read_status load(EST_TokenStream &ts, - const EST_String filetype, - int offset=0, - int length = 0, - int rate = default_sample_rate); - - /** Load a file of type filetype into the waveform. This - can be used to load unheadered files, in which case the fields - sample_rate, sample_type, bo and nc are used - to specify the sample rate, type, byte order and number of - channels. A portion of the waveform can be loaded by setting - offset to the sample position from the beginning and - to the number of required samples after this. - */ - - EST_read_status load_file(const EST_String filename, - const EST_String filetype, int sample_rate, - const EST_String sample_type, int bo, int nc, - int offset = 0, int length = 0); - EST_read_status load_file(EST_TokenStream &ts, - const EST_String filetype, int sample_rate, - const EST_String sample_type, int bo, int nc, - int offset = 0, int length = 0); - - /* Save waveform to a file called filename of file - format EST_filetype. - */ - EST_write_status save(const EST_String filename, - const EST_String EST_filetype = ""); - - EST_write_status save(FILE *fp, - const EST_String EST_filetype = ""); - - EST_write_status save_file(const EST_String filename, - EST_String filetype, - EST_String sample_type, int bo); - - EST_write_status save_file(FILE *fp, - EST_String filetype, - EST_String sample_type, int bo); - //@} - - /// Assignment operator - EST_Wave& operator = (const EST_Wave& w); - /** Add to existing wave in serial. Waveforms must have the same - number of channels. - */ - EST_Wave& operator +=(const EST_Wave &a); - /** Add wave in parallel, i.e. make wave a become new - channels in existing waveform. - */ - EST_Wave& operator |=(const EST_Wave &a); - - /// print waveform - friend ostream& operator << (ostream& p_values, const EST_Wave &sig); - - // integrity check *** debug - void integrity() const { p_values.integrity() ; } - -}; - -typedef EST_TList EST_WaveList; - -int operator != (EST_Wave a, EST_Wave b); -int operator == (EST_Wave a, EST_Wave b); - -#endif /* __Wave_H__ */ diff --git a/src/est/EST_bool.h b/src/est/EST_bool.h deleted file mode 100644 index 7217dcd11c..0000000000 --- a/src/est/EST_bool.h +++ /dev/null @@ -1,124 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /************************************************************************/ - /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */ - /* Date: Tue Apr 1 1997 */ - /************************************************************************/ - /* */ - /* Temporary bool type definition. */ - /* */ - /************************************************************************/ - -#ifndef __EST_BOOL_H__ -#define __EST_BOOL_H__ - -#ifdef __GNUC__ - - /* GCC seems to be so very fond of bool -- it's built into - * the compiler and it chokes on my definition. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef TRUE -#define TRUE (1==1) -#endif -#ifndef FALSE -#define FALSE (1==0) -#endif - -#ifdef __cplusplus -} -#endif - -#else - - /* For a boring type we still #define everything for code - * which uses ifdef to see if bool is defined. - */ - -#undef true -#undef false -#undef TRUE -#undef FALSE - -#ifdef __cplusplus -#if 0 - - class BoolType { - - private: - int p_val; - - public: - BoolType(int i) { p_val = i!=0;}; - BoolType() { p_val = 1==0;}; - - operator int () const { return p_val; }; - - BoolType operator == (BoolType b) const { return p_val == b.p_val;}; - BoolType operator != (BoolType b) const { return p_val != b.p_val;}; - - }; - -#define true BoolType(1) -#define false BoolType(0) -#define TRUE BoolType(1) -#define FALSE BoolType(0) -#define bool BoolType - -#else - -/* Because SunCC is stupid we pretend we can't do better than we */ -/* could with C. */ -#if __SUNPRO_CC_COMPAT != 5 -#define bool int -#endif -#define TRUE (1==1) -#define FALSE (1==0) -#define true TRUE -#define false FALSE - -#endif - -#else /* __cplusplus */ - -#define bool int -#define TRUE (1==1) -#define FALSE (1==0) - -#endif /* __cplusplus */ -#endif /* not __GNUC__ */ - -#endif diff --git a/src/est/EST_common.h b/src/est/EST_common.h deleted file mode 100644 index 57503d515f..0000000000 --- a/src/est/EST_common.h +++ /dev/null @@ -1,62 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /************************************************************************/ - /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */ - /* Date: Tue Apr 1 1997 */ - /************************************************************************/ - /* */ - /* A place for things to be seen by all of the speech tools. */ - /* */ - /************************************************************************/ - -#ifndef __EST_COMMON_H__ -#define __EST_COMMON_H__ - -/* all this stuff should be common to C and C++ */ - -#ifdef __cplusplus -extern "C" { -#endif - - /* Nasty, horrible, yeuch, like gag me with an algebra, man! */ -#include "EST_bool.h" - -#ifdef INCLUDE_DMALLOC -# include -# include -#endif - -#ifdef __cplusplus - } -#endif - -#endif diff --git a/src/est/EST_defines_win32.h b/src/est/EST_defines_win32.h deleted file mode 100644 index 93258ca2f6..0000000000 --- a/src/est/EST_defines_win32.h +++ /dev/null @@ -1,53 +0,0 @@ - - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - /* */ - /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */ - /* Date: Tue Sep4th 1997 */ - /* -------------------------------------------------------------------- */ - /* Defines for things which have to be hidden from some compilers. */ - /* */ - /*************************************************************************/ - -#if !defined(__EST_DEFINES_WIN32_H__) -#define __EST_DEFINES_WIN32_H__ 1 - -#define size_t unsigned int -#undef DIFFERENCE -#define M_PI (3.1415926) -#define isnan(N) 0 -#define isnanf(N) 0 - -#undef min -#undef max -#endif diff --git a/src/est/EST_filter.h b/src/est/EST_filter.h deleted file mode 100644 index 0ca14ade06..0000000000 --- a/src/est/EST_filter.h +++ /dev/null @@ -1,404 +0,0 @@ -/*************************************************************************/ -/* */ -/* Centre for Speech Technology Research */ -/* University of Edinburgh, UK */ -/* Copyright (c) 1995,1996 */ -/* All Rights Reserved. */ -/* */ -/* Permission is hereby granted, free of charge, to use and distribute */ -/* this software and its documentation without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of this work, and to */ -/* permit persons to whom this work is furnished to do so, subject to */ -/* the following conditions: */ -/* 1. The code must retain the above copyright notice, this list of */ -/* conditions and the following disclaimer. */ -/* 2. Any modifications must be clearly marked as such. */ -/* 3. Original authors' names are not deleted. */ -/* 4. The authors' names are not used to endorse or promote products */ -/* derived from this software without specific prior written */ -/* permission. */ -/* */ -/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ -/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ -/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ -/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ -/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ -/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ -/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ -/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ -/* THIS SOFTWARE. */ -/* */ -/*************************************************************************/ - - - - -#ifndef __EST_FILTER_H__ -#define __EST_FILTER_H__ - -#include "EST_Wave.h" -#include "EST_FMatrix.h" -#include "EST_Track.h" - -#define DEFAULT_PRE_EMPH_FACTOR 0.95 -#define DEFAULT_FILTER_ORDER 199 - -/**@name FIR filters - -Finite impulse response (FIR) filters which are useful for band-pass, -low-pass and high-pass filtering. - -FIR filters perform the following operation: - -\[y_t=\sum_{i=0}^{O-1} c_i \; x_{t-i}\] - -where \(O\) is the filter order, \(c_i\) are the filter coefficients, -\(x_t\) is the input at time \(t\) and \(y_t\) is the output at time -\(t\). Functions are provided for designing the filter (i.e. finding -the coefficients). - -*/ - -//@{ - -/** General purpose FIR filter. This function will filter the -waveform {\tt sig} with a previously designed filter, given as {\tt -numerator}. The filter coefficients can be designed using one of the -designed functions, e.g. \Ref{design_FIR_filter}. - -@see design_FIR_filter, design_lowpass_FIR_filter, design_highpass_FIR_filter, -@see FIRfilter, FIRlowpass_filter, FIRhighpass_filter - -*/ - -void FIRfilter(EST_Wave &in_sig, const EST_FVector &numerator, - int delay_correction=0); - - -/** General purpose FIR filter. This function will filter the -waveform {\tt sig} with a previously designed filter, given as {\tt -numerator}. The filter coefficients can be designed using one of the -designed functions, e.g. \Ref{design_FIR_filter} . - -@see design_FIR_filter, design_lowpass_FIR_filter, design_highpass_FIR_filter, -@see FIRfilter, FIRlowpass_filter, FIRhighpass_filter -*/ - -void FIRfilter(const EST_Wave &in_sig, EST_Wave &out_sig, - const EST_FVector &numerator, int delay_correction=0); - -/** General purpose FIR double (zero-phase) filter. This function -will double filter the waveform {\tt sig} with a previously designed -filter, given as {\tt numerator}. The filter coefficients can be -designed using one of the designed functions, -e.g. \Ref{design_FIR_filter}. Double filtering is performed by -filtering the signal normally, reversing the waveform, filtering -again and reversing the waveform again. Normal filtering will impose a -lag on the signal depending on the order of the filter. By filtering -the signal forwards and backwards, the lags cancel each other out and -the output signal is in phase with the input signal. - -@see design_FIR_filter, design_lowpass_FIR_filter, design_highpass_FIR_filter, -@see FIRfilter, FIRlowpass_filter, FIRhighpass_filter -*/ -void FIR_double_filter(EST_Wave &in_sig, EST_Wave &out_sig, - const EST_FVector &numerator); - -/** Quick function for one-off low pass filtering. If repeated lowpass -filtering is needed, first design the required filter using -\Ref{design_lowpass_filter}, and then use \Ref{FIRfilter} to do the actual -filtering. - -@see design_FIR_filter, design_lowpass_FIR_filter, design_highpass_FIR_filter, FIRfilter, FIRhighpass_filter, FIRlowpass_filter - -@param in_sig input waveform, which will be overwritten -@param freq -@param order number of filter coefficients, eg. 99 -*/ - -void FIRlowpass_filter(EST_Wave &sigin, int freq, int order=DEFAULT_FILTER_ORDER); - -/** Quick function for one-off low pass filtering. If repeated lowpass -filtering is needed, first design the required filter using -\Ref{design_lowpass_filter}, and then use \Ref{FIRfilter} to do the actual -filtering. - -@param in_sig input waveform -@param out_sig output waveform -@param freq cutoff frequency in Hertz -@param order number of filter coefficients , e.g. 99 - -@see design_FIR_filter, design_lowpass_FIR_filter, design_highpass_FIR_filter, FIRfilter, FIRhighpass_filter -*/ - -void FIRlowpass_filter(const EST_Wave &in_sig, EST_Wave &out_sig, - int freq, int order=DEFAULT_FILTER_ORDER); - -/** Quick function for one-off high pass filtering. If repeated lowpass -filtering is needed, first design the required filter using -design_lowpass_filter, and then use FIRfilter to do the actual -filtering. - -@param in_sig input waveform, which will be overwritten -@param freq cutoff frequency in Hertz -@param order number of filter coefficients, eg. 99 - -@see design_FIR_filter, design_lowpass_FIR_filter, design_highpass_FIR_filter -@see FIRfilter, FIRlowpass_filter, FIRhighpass_filter -*/ - -void FIRhighpass_filter(EST_Wave &in_sig, int freq, int order); - -/** Quick function for one-off high pass filtering. If repeated highpass -filtering is needed, first design the required filter using -design_highpass_filter, and then use FIRfilter to do the actual -filtering. - -@param in_sig input waveform -@param out_sig output waveform -@param freq cutoff frequency in Hertz -@param order number of filter coefficients, eg. 99 - -@see design_FIR_filter, design_lowpass_FIR_filter, design_highpass_FIR_filter -@see FIRfilter, FIRlowpass_filter, FIRhighpass_filter -*/ -void FIRhighpass_filter(const EST_Wave &sigin, EST_Wave &out_sig, - int freq, int order=DEFAULT_FILTER_ORDER); - - -/** Quick function for one-off double low pass filtering. - -Normal low pass filtering (\Ref{FIRlowpass_filter}) introduces a time delay. -This function filters the signal twice, first forward and then backwards, -which ensures a zero phase lag. Hence the order parameter need only be -half what it is for (\Ref{FIRlowpass_filter} to achieve the same effect. - -@param in_sig input waveform, which will be overwritten -@param freq cutoff frequency in Hertz -@param order number of filter coefficients, eg. 99 - -@see FIRhighpass_filter -*/ -void FIRhighpass_double_filter(EST_Wave &sigin, int freq, - int order=DEFAULT_FILTER_ORDER); - -/** Quick function for one-off double low pass filtering. - -Normal low pass filtering (\Ref{FIRlowpass_filter}) introduces a time delay. -This function filters the signal twice, first forward and then backwards, -which ensures a zero phase lag. Hence the order parameter need only be -half what it is for (\Ref{FIRlowpass_filter} to achieve the same effect. - -@param in_sig input waveform -@param out_sig output waveform -@param freq cutoff frequency in Hertz -@param order number of filter coefficients, eg. 99 - -@see FIRhighpass_filter - -*/ -void FIRhighpass_double_filter(const EST_Wave &int_sig, EST_Wave &out_sig, - int freq, int order=DEFAULT_FILTER_ORDER); - -/** Quick function for one-off zero phase high pass filtering. - -Normal high pass filtering (\Ref{FIRhighpass_filter}) introduces a time delay. -This function filters the signal twice, first forward and then backwards, -which ensures a zero phase lag. Hence the order parameter need only be -half what it is for (\Ref{FIRhighpass_filter} to achieve the same effect. - -@param in_sig input waveform, which will be overwritten -@param freq cutoff frequency in Hertz -@param order number of filter coefficients, eg. 99 - -@see FIRlowpass_filter -*/ -void FIRlowpass_double_filter(EST_Wave &sigin, int freq, - int order=DEFAULT_FILTER_ORDER); - -/** Quick function for one-off zero phase high pass filtering. - -Normal high pass filtering (\Ref{FIRhighpass_filter}) introduces a time delay. -This function filters the signal twice, first forward and then backwards, -which ensures a zero phase lag. Hence the order parameter need only be -half what it is for (\Ref{FIRhighpass_filter} to achieve the same effect. - -@param in_sig input waveform -@param out_sig output waveform -@param freq cutoff frequency in Hertz -@param order number of filter coefficients, eg. 99 - -@see FIRlowpass_filter -*/ -void FIRlowpass_double_filter(const EST_Wave &in_sig, EST_Wave &out_sig, - int freq, int order=DEFAULT_FILTER_ORDER); - -//@} - -/**@name Linear Prediction filters - -The linear prediction filters are used for the analysis and synthesis of -waveforms according the to linear prediction all-pole model. - -The linear prediction states that the value of a signal at a given -point is equal to a weighted sum of the previous P values, plus a -correction value for that point: - -\[s_{n} = \sum_{i=1}^{P} a_{i}.s_{n-i} + e_{n}\] - -Given a set of coefficients and the original signal, we can use this -equation to work out e, the {\it residual}. Conversely given the -coefficients and the residual signal, an estimation of the original -signal can be calculated. - -If a single set of coefficients were used for the entire waveform, the -filtering process would be simple. It is usual however to have a -different set of coefficients for every frame, and there are many -possible ways to switch from one coefficient set to another so as not -to cause discontinuities at the frame boundaries. -*/ - -//@{ - -/** Synthesize a signal from a single set of linear prediction -coefficients and the residual values. - -@param sig the waveform to be synthesized -@param a a single set of LP coefficients -@param res the input residual waveform -*/ -void lpc_filter(EST_Wave &sig, EST_FVector &a, EST_Wave &res); - -/** Filter the waveform using a single set of coefficients so as to -produce a residual signal. - -@param sig the speech waveform to be filtered -@param a a single set of LP coefficients -@param res the output residual waveform -*/ - -void inv_lpc_filter(EST_Wave &sig, EST_FVector &a, EST_Wave &res); - -/** Synthesize a signal from a track of linear prediction coefficients. -This function takes a set of LP frames and a residual and produces a -synthesized signal. - -For each frame, the function picks an end point, which is half-way -between the current frame's time position and the next frame's. A -start point is defined as being the previous frame's end. Using these -two values, a portion of residual is extracted and passed to -\Ref{lpc_filter} along with the LP coefficients for that frame. This -function writes directly into the signal for the values between start -and end; - -@param sig the waveform to be synthesized -@param lpc a track of time positioned LP coefficients -@param res the input residual waveform -*/ - -void lpc_filter_1(EST_Track &lpc, EST_Wave & res, EST_Wave &sig); - -/** Synthesize a signal from a track of linear prediction coefficients. -This function takes a set of LP frames and a residual and produces a -synthesized signal. - -This is functionally equivalent to \Ref{lpc_filter_1} except it -reduces the residual by 0.5 before filtering. Importantly it is -about three times faster than \Ref{lpc_filter_1} but in doing so uses -direct C buffers rather than the neat C++ access function. This -function should be regarded as temporary and will be deleted after -we restructure the low level classes to give better access. - -@param sig the waveform to be synthesized -@param lpc a track of time positioned LP coefficients -@param res the input residual waveform -*/ - -void lpc_filter_fast(EST_Track &lpc, EST_Wave & res, EST_Wave &sig); - -/** Produce a residual from a track of linear prediction coefficients -and a signal using an overlap add technique. - -For each frame, the function estimates the local pitch period and -picks a start point one period before the current time position and an -end point one period after it. - -A portion of residual corresponding to these times is then produced -using \Ref{inv_lpc_filter}. The resultant section of residual is then -overlap-added into the main residual wave object. - -@param sig the speech waveform to be filtered -@param lpc a track of time positioned LP coefficients -@param res the output residual waveform -*/ - -void inv_lpc_filter_ola(EST_Wave &sig, EST_Track &lpc, EST_Wave &res); - -//@} - -/**@name Pre/Post Emphasis filters. - -These functions adjust the spectral tilt of the input waveform. - -*/ - -//@{ - -/** Pre-emphasis filtering. This performs simple high pass -filtering with a one tap filter of value {\tt a}. Normal values of a -range between 0.95 and 0.99. */ - -void pre_emphasis(EST_Wave &sig, float a=DEFAULT_PRE_EMPH_FACTOR); - -/** Pre-emphasis filtering. This performs simple high pass -filtering with a one tap filter of value {\tt a}. Normal values of a -range between 0.95 and 0.99. */ - - -void pre_emphasis(EST_Wave &sig, EST_Wave &out, - float a=DEFAULT_PRE_EMPH_FACTOR); - -/** Post-emphasis filtering. This performs simple low pass -filtering with a one tap filter of value a. Normal values of a range -between 0.95 and 0.99. The same values of {\tt a} should be used when -pre- and post-emphasizing the same signal. */ - -void post_emphasis(EST_Wave &sig, float a=DEFAULT_PRE_EMPH_FACTOR); - -/** Post-emphasis filtering. This performs simple low pass -filtering with a one tap filter of value a. Normal values of a range -between 0.95 and 0.99. The same values of {\tt a} should be used when -pre- and post-emphasizing the same signal. */ - -void post_emphasis(EST_Wave &sig, EST_Wave &out, - float a=DEFAULT_PRE_EMPH_FACTOR); - -//@} - -/**@name Miscellaneous filters. - -Some of these filters are non-linear and therefore don't fit the -normal paradigm. - -*/ //@{ - -/** Filters the waveform by means of median smoothing. - -This is a sort of low pass filter which aims to remove extreme values. -Median smoothing works examining each sample in the wave, taking all -the values in a window of size {\tt n} around that sample, sorting -them and replacing that sample with the middle ranking sample in the -sorted samples. - -@param sig waveform to be filtered -@param n size of smoothing window - -*/ - -void simple_mean_smooth(EST_Wave &c, int n); - -//@} - -#endif /* __EST_FILTER_H__ */ - diff --git a/src/est/EST_iostream.h b/src/est/EST_iostream.h deleted file mode 100644 index e8c6271ba3..0000000000 --- a/src/est/EST_iostream.h +++ /dev/null @@ -1,59 +0,0 @@ - - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - /* */ - /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */ - /* Date: Tue Sep4th 1997 */ - /* -------------------------------------------------------------------- */ - /* Wrapper around iostream.h because the visual C++ clashes with some */ - /* unix stuff. */ - /* */ - /*************************************************************************/ - -#if !defined(EST_IOSTREAM_H) -# define EST_IOSTREAM_H 1 - -#include "EST_system.h" - -#if defined(__EMX__) - /* For OS/2 */ -# include -#elif defined(SYSTEM_IS_UNIX) -# include -#elif defined(SYSTEM_IS_WIN32) -# include "EST_iostream_win32.h" -#else -# error No System Selected -#endif - -#endif diff --git a/src/est/EST_rw_status.h b/src/est/EST_rw_status.h deleted file mode 100644 index 834b5e4774..0000000000 --- a/src/est/EST_rw_status.h +++ /dev/null @@ -1,158 +0,0 @@ -/*************************************************************************/ -/* */ -/* Centre for Speech Technology Research */ -/* University of Edinburgh, UK */ -/* Copyright (c) 1994,1995,1996 */ -/* All Rights Reserved. */ -/* */ -/* Permission is hereby granted, free of charge, to use and distribute */ -/* this software and its documentation without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of this work, and to */ -/* permit persons to whom this work is furnished to do so, subject to */ -/* the following conditions: */ -/* 1. The code must retain the above copyright notice, this list of */ -/* conditions and the following disclaimer. */ -/* 2. Any modifications must be clearly marked as such. */ -/* 3. Original authors' names are not deleted. */ -/* 4. The authors' names are not used to endorse or promote products */ -/* derived from this software without specific prior written */ -/* permission. */ -/* */ -/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ -/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ -/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ -/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ -/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ -/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ -/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ -/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ -/* THIS SOFTWARE. */ -/* */ -/*************************************************************************/ -/* Author : Paul Taylor */ -/* Date : April 1994 */ -/*-----------------------------------------------------------------------*/ -/* Utility Function header file for C and C++ */ -/* */ -/*=======================================================================*/ - -#ifndef __RW_STATUS_H__ -#define __RW_STATUS_H__ - - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - - /* - * make_status_int builds the status as an integer - * make_X_status casts it to the required type. - */ - -#define make_status_int(STATE, REASON, ERRNO) \ - ( ((((unsigned int)(STATE)) & 0xff) <<24) \ - | ((((unsigned int)(REASON)) & 0xff) <<16) \ - | ((((unsigned int)(ERRNO)) & 0xffff) <<00) \ - ) - -#define make_read_status(STATE, REASON, ERRNO)\ - ((EST_read_status)(make_status_int(STATE, REASON, ERRNO))) - -#define make_write_status(STATE, REASON, ERRNO) \ - ((EST_write_status)(make_status_int(REASON, STATE, ERRNO))) - - /* - * Extract the bits. - */ - -#define get_rw_state(STATUS) \ - ((EST_rw_state)((((unsigned int)(STATUS)) >> 24) & 0xff)) -#define get_rw_reason(STATUS) \ - ((EST_rw_reason)((((unsigned int)(STATUS)) >> 16) & 0xff)) -#define get_rw_errno(STATUS) \ - ((int)((((unsigned int)(STATUS)) >> 0) & 0xff)) - - - /* - * Why we failed. - */ - -enum EST_rw_reason { - rwr_none=0, - rwr_format=1, - rwr_existance=2, - rwr_permission=3, - rwr_system=4, - rwr_unknown=0xff -}; - -/** State of rw */ -enum EST_rw_state { - /// ok - rws_ok=0, - /// partial - rws_partial=1, - /// failed - rws_failed=0xff -}; - - -/** Possible outcomes of a file reading operation. More stuff*/ -enum EST_read_status { - /// The file was read in successfully - read_ok = make_status_int(rws_ok, rwr_none, 0), - /// The file exists but is not in the format specified - read_format_error = make_status_int(rws_failed, rwr_format, 0), - /// The file does not exist. - read_not_found_error = make_status_int(rws_failed, rwr_existance, 0), - /// An error occurred while reading - read_error = make_status_int(rws_failed, rwr_unknown, 0) -}; - - -/** Possible outcomes of a file writing operation */ -enum EST_write_status { - /// The file was written successfully - write_ok = make_status_int(rws_ok, rwr_none, 0), - /// The file was not written successfully - write_fail = make_status_int(rws_failed, rwr_unknown, 0), - /// The file was not written successfully - write_error = make_status_int(rws_failed, rwr_unknown, 0), - /// A valid file was created, but only some of the requested data is in there - write_partial = make_status_int(rws_partial, rwr_unknown, 0) -}; - -/** Possible outcomes of a network connection operation */ -enum EST_connect_status { - /// Connection made. - connect_ok = make_status_int(rws_ok, rwr_none, 0), - /// Connection failed. - connect_not_found_error = make_status_int(rws_failed, rwr_existance, 0), - /// Connection failed. - connect_not_allowed_error = make_status_int(rws_failed, rwr_permission, 0), - /// System failure of some kind - connect_system_error = make_status_int(rws_failed, rwr_system, 0), - /// The file was not written successfully - connect_error = make_status_int(rws_failed, rwr_unknown, 0) -}; - - - -#ifdef __cplusplus -} -#endif - -/* - * Temporary redefinitions of the old values. - */ - -#define format_ok read_ok -#define wrong_format read_format_error -#define misc_read_error read_error -#define misc_write_error write_error - -#endif /*__RW_STATUS_H__ */ diff --git a/src/est/EST_strcasecmp.h b/src/est/EST_strcasecmp.h deleted file mode 100644 index 44fc2b6af4..0000000000 --- a/src/est/EST_strcasecmp.h +++ /dev/null @@ -1,66 +0,0 @@ - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /************************************************************************/ - /* */ - /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */ - /* Date: Wed Jun 25 1997 */ - /* -------------------------------------------------------------------- */ - /* */ - /* Declaration for string comparison operation. */ - /* */ - /************************************************************************/ - -#ifndef __EST_STRCASECMP_H__ -#define __EST_STRCASECMP_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -int EST_strcasecmp(const char *s1, const char *s2, - const unsigned char *charmap); -int EST_strncasecmp(const char *s1, const char *s2, - size_t n, const unsigned char *charmap); - -#ifdef __cplusplus - } - -inline int EST_strcasecmp(const char *s1, const char *s2) - { return EST_strcasecmp(s1, s2, NULL); }; -inline int EST_strncasecmp(const char *s1, const char *s2, size_t n) - { return EST_strncasecmp(s1, s2, n, NULL); }; - -#endif - -#endif diff --git a/src/est/EST_types.h b/src/est/EST_types.h deleted file mode 100644 index 538834519d..0000000000 --- a/src/est/EST_types.h +++ /dev/null @@ -1,81 +0,0 @@ -/*************************************************************************/ -/* */ -/* Centre for Speech Technology Research */ -/* University of Edinburgh, UK */ -/* Copyright (c) 1995,1996 */ -/* All Rights Reserved. */ -/* */ -/* Permission is hereby granted, free of charge, to use and distribute */ -/* this software and its documentation without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of this work, and to */ -/* permit persons to whom this work is furnished to do so, subject to */ -/* the following conditions: */ -/* 1. The code must retain the above copyright notice, this list of */ -/* conditions and the following disclaimer. */ -/* 2. Any modifications must be clearly marked as such. */ -/* 3. Original authors' names are not deleted. */ -/* 4. The authors' names are not used to endorse or promote products */ -/* derived from this software without specific prior written */ -/* permission. */ -/* */ -/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ -/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ -/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ -/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ -/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ -/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ -/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ -/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ -/* THIS SOFTWARE. */ -/* */ -/*************************************************************************/ -/* Author : Paul Taylor */ -/* Date : July 1996 */ -/*-----------------------------------------------------------------------*/ -/* Type defines for Common Types */ -/* */ -/*=======================================================================*/ - -#ifndef __EST_TYPES_H__ -#define __EST_TYPES_H__ - -#include "EST_TList.h" -#include "EST_TVector.h" -#include "EST_String.h" -#include "EST_TKVL.h" -#include "EST_FMatrix.h" -#include "EST_DMatrix.h" -#include "EST_IMatrix.h" -#include "EST_SMatrix.h" - -typedef EST_TVector EST_StrVector; - -typedef EST_TSimpleVector EST_IVector; -typedef EST_TSimpleVector EST_SVector; -typedef EST_TSimpleVector EST_CVector; - -// DVector is an inherited TSimpleVector in EST_DMatrix.h -// FVector is an inherited TSimpleVector in EST_FMatrix.h - -typedef EST_TList EST_IList; -typedef EST_TList EST_FList; -typedef EST_TList EST_DList; - -typedef EST_TKVL EST_II_KVL; - -typedef EST_TList > EST_IListList; - -typedef EST_TList EST_StrList; -typedef EST_TList EST_IList; -typedef EST_TList EST_FList; - -typedef EST_TList > EST_StrListList; -typedef EST_TVector EST_StrListVector; -typedef EST_TKVL EST_StrStr_KVL; -typedef EST_TKVL EST_StrI_KVL; -typedef EST_TKVL EST_StrF_KVL; -typedef EST_TKVL EST_StrD_KVL; -//typedef EST_TKVL EST_StrVal_KVL; - -#endif // __EST_TYPES_H__ diff --git a/src/est/EST_walloc.h b/src/est/EST_walloc.h deleted file mode 100644 index 370a2a79ef..0000000000 --- a/src/est/EST_walloc.h +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************/ -/* */ -/* Centre for Speech Technology Research */ -/* University of Edinburgh, UK */ -/* Copyright (c) 1994,1995,1996 */ -/* All Rights Reserved. */ -/* */ -/* Permission is hereby granted, free of charge, to use and distribute */ -/* this software and its documentation without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of this work, and to */ -/* permit persons to whom this work is furnished to do so, subject to */ -/* the following conditions: */ -/* 1. The code must retain the above copyright notice, this list of */ -/* conditions and the following disclaimer. */ -/* 2. Any modifications must be clearly marked as such. */ -/* 3. Original authors' names are not deleted. */ -/* 4. The authors' names are not used to endorse or promote products */ -/* derived from this software without specific prior written */ -/* permission. */ -/* */ -/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ -/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ -/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ -/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ -/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ -/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ -/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ -/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ -/* THIS SOFTWARE. */ -/* */ -/*************************************************************************/ -/* Author : Paul Taylor and Alan W Black */ -/* Date : July 1996 */ -/*-----------------------------------------------------------------------*/ -/* Safe(-er) allocation functions. */ -/* */ -/*=======================================================================*/ - -#if !defined(__EST_WALLOC_H__) - -#if defined(__cplusplus) -extern "C" { -#endif - -void *safe_walloc(int size); -void *safe_wcalloc(int size); -void *safe_wrealloc(void *ptr, int size); -#define walloc(TYPE,SIZE) ((TYPE *)safe_walloc(sizeof(TYPE)*(SIZE))) -#define wcalloc(TYPE,SIZE) ((TYPE *)safe_wcalloc(sizeof(TYPE)*(SIZE))) -#define wrealloc(PTR,TYPE,SIZE) ((TYPE *)safe_wrealloc((void *)(PTR), sizeof(TYPE)*(SIZE))) -char *wstrdup(const char *s); -void wfree(void *p); - -#if defined(__cplusplus) -} -#endif - -#endif diff --git a/src/est/est_iostream_win32.h b/src/est/est_iostream_win32.h deleted file mode 100644 index bee0647805..0000000000 --- a/src/est/est_iostream_win32.h +++ /dev/null @@ -1,51 +0,0 @@ - - - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - /* */ - /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */ - /* Date: Tue Sep4th 1997 */ - /* -------------------------------------------------------------------- */ - /* Wrapper around iostream includes to avoid aome win32 nasties. */ - /* */ - /*************************************************************************/ - -#if !defined(__EST_IOSTREAM_WIN32_H__) -# define __EST_IOSTREAM_WIN32_H__ 1 - -#include - -#undef read -#undef write - -#endif diff --git a/src/est/est_system.h b/src/est/est_system.h deleted file mode 100644 index f584d15168..0000000000 --- a/src/est/est_system.h +++ /dev/null @@ -1,60 +0,0 @@ - - /************************************************************************/ - /* */ - /* Centre for Speech Technology Research */ - /* University of Edinburgh, UK */ - /* Copyright (c) 1996,1997 */ - /* All Rights Reserved. */ - /* */ - /* Permission is hereby granted, free of charge, to use and distribute */ - /* this software and its documentation without restriction, including */ - /* without limitation the rights to use, copy, modify, merge, publish, */ - /* distribute, sublicense, and/or sell copies of this work, and to */ - /* permit persons to whom this work is furnished to do so, subject to */ - /* the following conditions: */ - /* 1. The code must retain the above copyright notice, this list of */ - /* conditions and the following disclaimer. */ - /* 2. Any modifications must be clearly marked as such. */ - /* 3. Original authors' names are not deleted. */ - /* 4. The authors' names are not used to endorse or promote products */ - /* derived from this software without specific prior written */ - /* permission. */ - /* */ - /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ - /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ - /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ - /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ - /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ - /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ - /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ - /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ - /* THIS SOFTWARE. */ - /* */ - /*************************************************************************/ - /* */ - /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */ - /* Date: Tue Sep4th 1997 */ - /* -------------------------------------------------------------------- */ - /* Make all systems look similar enough to unix to be easy to cope with. */ - /* */ - /*************************************************************************/ - -#if !defined(EST_SYSTEM_H) -# define EST_SYSTEM_H 1 - -#define SYSTEM_IS_WIN32 -#if defined(SYSTEM_IS_WIN32) -# define _WINSOCKAPI_ /* horrible hack */ -# include -# include -# include "EST_defines_win32.h" -# if defined(_MSC_VER) -# define VISUAL_CPP 1 -# endif -#else -# define SYSTEM_IS_UNIX 1 -# include -# include "unix/EST_defines_unix.h" -#endif - -#endif diff --git a/src/est/readme.txt b/src/est/readme.txt deleted file mode 100644 index ffb866eb84..0000000000 --- a/src/est/readme.txt +++ /dev/null @@ -1,3 +0,0 @@ -The Edinburgh Speech Tools Library -Centre for Speech Technology Research -http://www.cstr.ed.ac.uk/projects/speech_tools/ \ No newline at end of file diff --git a/src/est/srpd.h b/src/est/srpd.h deleted file mode 100644 index d6b4ba43bf..0000000000 --- a/src/est/srpd.h +++ /dev/null @@ -1,138 +0,0 @@ -/*************************************************************************/ -/* */ -/* Centre for Speech Technology Research */ -/* University of Edinburgh, UK */ -/* Copyright (c) 1995,1996 */ -/* All Rights Reserved. */ -/* */ -/* Permission is hereby granted, free of charge, to use and distribute */ -/* this software and its documentation without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of this work, and to */ -/* permit persons to whom this work is furnished to do so, subject to */ -/* the following conditions: */ -/* 1. The code must retain the above copyright notice, this list of */ -/* conditions and the following disclaimer. */ -/* 2. Any modifications must be clearly marked as such. */ -/* 3. Original authors' names are not deleted. */ -/* 4. The authors' names are not used to endorse or promote products */ -/* derived from this software without specific prior written */ -/* permission. */ -/* */ -/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ -/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ -/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ -/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ -/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ -/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ -/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ -/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ -/* THIS SOFTWARE. */ -/* */ -/*************************************************************************/ -/* Author : Paul Taylor */ -/* Date : April 1994 */ -/*************************************************************************/ -#ifndef __SRPD_H__ -#define __SRPD_H__ - -#include - -/******************** - * define constants * - ********************/ - -#define MINARG 5 -#define BREAK_NUMBER 0.0 - -#define DEFAULT_DECIMATION 4 /* samples */ -#define DEFAULT_MIN_PITCH 40.0 /* Hz */ -#define DEFAULT_MAX_PITCH 400.0 /* Hz */ - -#define DEFAULT_SF 20000 /* Hz. Sampling Frequency */ -#define DEFAULT_SHIFT 5.0 /* ms */ -#define DEFAULT_LENGTH 10.0 /* ms */ -#define DEFAULT_TSILENT 120 /* max. abs sample amplitude of noise */ -#define DEFAULT_TMIN 0.75 -#define DEFAULT_TMAX_RATIO 0.85 -#define DEFAULT_THIGH 0.88 -#define DEFAULT_TDH 0.77 - -#define UNVOICED 0 /* segment classifications */ -#define VOICED 1 -#define SILENT 2 - -#define HOLD 1 -#define HELD 1 -#define SEND 2 -#define SENT 2 - -/****************************** - * define abstract data types * - ******************************/ - -struct CROSS_CORR_ -{ - int size; - double *coeff; -} ; - - -struct SEGMENT_ -{ /* segment of speech data */ - int size, shift, length; /* in samples */ - short *data; -}; - - -struct Srpd_Op { - int sample_freq; /* Hz */ - int Nmax, Nmin; - double shift, length; /* ms */ - double min_pitch; /* Hz */ - double max_pitch; /* Hz */ - int L; /* Decimation factor (samples) */ - double Tmin, Tmax_ratio, Thigh, Tdh; - int Tsilent; - int make_ascii; - int peak_tracking; -}; - -struct STATUS_ { - double pitch_freq; - char v_uv, s_h; - double cc_max, threshold; -}; - -typedef struct list { - int N0, score; - struct list *next_item; -} LIST_; - -typedef enum { - CANT_WRITE, DECI_FCTR, INSUF_MEM, FILE_ERR, FILE_SEEK, LEN_OOR, MAX_FREQ, - MIN_FREQ, MISUSE, NOISE_FLOOR, SAMPLE_FREQ, SFT_OOR, THR_DH, THR_HIGH, - THR_MAX_RTO, THR_MIN - } error_flags; - - -void add_to_list (LIST_ **p_list_hd, LIST_ **p_list_tl, int N_val, - int score_val); - -void super_resolution_pda (struct Srpd_Op *paras, SEGMENT_ seg, - CROSS_CORR_ *p_cc, STATUS_ *p_status); -void write_track(STATUS_ status, struct Srpd_Op paras, FILE *outfile); - - -int read_next_segment (FILE *voxfile, struct Srpd_Op *paras, SEGMENT_ *p_seg); -void end_structure_use(SEGMENT_ *p_seg, CROSS_CORR_ *p_cc); -void initialise_status (struct Srpd_Op *p, STATUS_ *p_status); -void initialise_structures (struct Srpd_Op *p, SEGMENT_ *p_seg, - CROSS_CORR_ *p_cc); - -void initialise_parameters (struct Srpd_Op *p_par); -void error (error_flags err_type); - -void free_list (LIST_ **p_list_hd); - -#endif // __SRPD_H__