BOOL ConsoleKillFocus( HWND hWnd, HANDLE hConsole ) { PCONSOLE_TABLE ConTbl; ConTbl = SearchConsole(hConsole); if (ConTbl == NULL) { DBGPRINT(("CONIME: Error! Cannot found registed Console\n")); return FALSE; } if ( gfDoNotKillFocus ){ gfDoNotKillFocus = FALSE; } else{ //v-hirshi Jun.13.1996 #if defined(LATER_DBCS) // kazum ImmSetActiveContextConsoleIME(hWnd, FALSE); //v-hirshi Jun.13.1996 #endif ImmAssociateContext(hWnd, ghDefaultIMC); } #ifdef DEBUG_MODE DisplayInformation(hWnd, hConsole); #endif return TRUE; }
BOOL InsertNewConsole( HWND hWnd, HANDLE hConsole, HWND hWndConsole ) { // conime receive ime message from console before 1st console registered. // this will happen after restart conime when conime dead by bogus ime's AV or // other problem // so this fail safe code is necessary to protect consrv. if (SearchConsole(hConsole) != NULL) { return TRUE; } LockConsoleTable(); if (!InsertConsole(hWnd, hConsole, hWndConsole)) { UnlockConsoleTable(); return FALSE; } #ifdef DEBUG_MODE DisplayInformation(hWnd, hConsole); #endif ImeUISetOpenStatus( hWndConsole ); UnlockConsoleTable(); return TRUE; }
BOOL ConsoleSetFocus( HWND hWnd, HANDLE hConsole, HKL hKL ) { PCONSOLE_TABLE ConTbl; HKL OldhKL; ConTbl = SearchConsole(hConsole); if (ConTbl == NULL) { DBGPRINT(("CONIME: Error! Cannot found registed Console\n")); return FALSE; } if ( gfDoNotKillFocus ){ gfDoNotKillFocus = FALSE; } OldhKL = ConTbl->hklActive ; ConTbl->hklActive = hKL; ActivateKeyboardLayout(ConTbl->hklActive, 0); ImmAssociateContext(hWnd, ConTbl->hIMC_Current); if (OldhKL == 0) { GetIMEName( ConTbl ); ConTbl->ImmGetProperty = ImmGetProperty(ConTbl->hklActive , IGP_PROPERTY); } //v-hirshi Jun.13.1996 #if defined(LATER_DBCS) // kazum ImmSetActiveContextConsoleIME(hWnd, TRUE); //v-hirshi Jun.13.1996 #endif LastConsole = hConsole; #ifdef DEBUG_MODE DisplayInformation(hWnd, hConsole); #endif ImeUISetOpenStatus( hWnd ); if (ConTbl->lpCompStrMem != NULL) ReDisplayCompositionStr( hWnd ); return TRUE; }
HRESULT CDisplayGPSData::IsValidPosition(__in GPS_POSITION gps_Position) { //GPS_POSITION m_GPS_Position = gps_Position; if((!gpsLock) && (gps_Position.flHorizontalDilutionOfPrecision > 0) && (gps_Position.flHorizontalDilutionOfPrecision < 50) && ((gps_Position.flHorizontalDilutionOfPrecision != best_GPS_Position.flHorizontalDilutionOfPrecision) || (gps_Position.dwSatelliteCount > best_GPS_Position.dwSatelliteCount))){ //Initialize the first GPS Position //if(number_of_GPS_Positions == 0){ // best_GPS_Position = gps_Position; //} //Increment the number of GPS positions if(best_GPS_Position.dwSatelliteCount >= 3){ number_of_GPS_Positions++; } if(best_GPS_Position.dwSatelliteCount < gps_Position.dwSatelliteCount){ best_GPS_Position = gps_Position; } else if(best_GPS_Position.dwSatelliteCount == gps_Position.dwSatelliteCount){ if(best_GPS_Position.flHorizontalDilutionOfPrecision > gps_Position.flHorizontalDilutionOfPrecision){ best_GPS_Position = gps_Position; } } if(((best_GPS_Position.dwSatelliteCount >=3) && (best_GPS_Position.flHorizontalDilutionOfPrecision < 2)) || (number_of_GPS_Positions >= 8)){ DisplayInformation(); } } return S_OK; }
//----------------------------------------------------------------------------- // Test program. // test.exe input.wav outout.wav f0 spec flag // input.wav : argv[1] Input file // output.wav : argv[2] Output file // f0 : argv[3] F0 scaling (a positive number) // spec : argv[4] Formant shift (a positive number) //----------------------------------------------------------------------------- int main(int argc, char *argv[]) { if (argc != 2 && argc != 3 && argc != 4 && argc != 5) { printf("error\n"); return -2; } // 2016/01/28: Important modification. // Memory allocation is carried out in advanse. // This is for compatibility with C language. int x_length = GetAudioLength(argv[1]); if (x_length <= 0) { if (x_length == 0) printf("error: File not found.\n"); else printf("error: The file is not .wav format.\n"); return -1; } double *x = new double[x_length]; // wavread() must be called after GetAudioLength(). int fs, nbit; wavread(argv[1], &fs, &nbit, x); DisplayInformation(fs, nbit, x_length); //--------------------------------------------------------------------------- // Analysis part //--------------------------------------------------------------------------- // 2016/02/02 // A new struct is introduced to implement safe program. WorldParameters world_parameters = { 0 }; // You must set fs and frame_period before analysis/synthesis. world_parameters.fs = fs; // 5.0 ms is the default value. // Generally, the inverse of the lowest F0 of speech is the best. // However, the more elapsed time is required. world_parameters.frame_period = 5.0; // F0 estimation // DIO // F0EstimationDio(x, x_length, &world_parameters); // Harvest F0EstimationHarvest(x, x_length, &world_parameters); // Spectral envelope estimation SpectralEnvelopeEstimation(x, x_length, &world_parameters); // Aperiodicity estimation by D4C AperiodicityEstimation(x, x_length, &world_parameters); // Note that F0 must not be changed until all parameters are estimated. ParameterModification(argc, argv, fs, world_parameters.f0_length, world_parameters.fft_size, world_parameters.f0, world_parameters.spectrogram); //--------------------------------------------------------------------------- // Synthesis part (2016/04/19) // There are three samples in speech synthesis // 1: Conventional synthesis // 2: Example of real-time synthesis // 3: Example of real-time synthesis (Ring buffer is efficiently used) //--------------------------------------------------------------------------- char filename[100]; // The length of the output waveform int y_length = static_cast<int>((world_parameters.f0_length - 1) * world_parameters.frame_period / 1000.0 * fs) + 1; double *y = new double[y_length]; // Synthesis 1 (conventional synthesis) for (int i = 0; i < y_length; ++i) y[i] = 0.0; WaveformSynthesis(&world_parameters, fs, y_length, y); sprintf(filename, "01%s", argv[2]); wavwrite(y, y_length, fs, 16, filename); // Synthesis 2 (All frames are added at the same time) for (int i = 0; i < y_length; ++i) y[i] = 0.0; WaveformSynthesis2(&world_parameters, fs, y_length, y); sprintf(filename, "02%s", argv[2]); wavwrite(y, y_length, fs, 16, filename); // Synthesis 3 (Ring buffer is efficiently used.) for (int i = 0; i < y_length; ++i) y[i] = 0.0; WaveformSynthesis3(&world_parameters, fs, y_length, y); sprintf(filename, "03%s", argv[2]); wavwrite(y, y_length, fs, 16, filename); delete[] y; delete[] x; DestroyMemory(&world_parameters); printf("complete.\n"); return 0; }
//----------------------------------------------------------------------------- // Test program. // test.exe input.wav outout.wav f0 spec flag // input.wav : argv[1] Input file // output.wav : argv[2] Output file // f0 : argv[3] F0 scaling (a positive number) // spec : argv[4] Formant shift (a positive number) //----------------------------------------------------------------------------- int main(int argc, char *argv[]) { if (argc != 2 && argc != 3 && argc != 4 && argc != 5) { printf("error\n"); return -2; } // 2016/01/28: Important modification. // Memory allocation is carried out in advanse. // This is for compatibility with C language. int x_length = GetAudioLength(argv[1]); if (x_length <= 0) { if (x_length == 0) printf("error: File not found.\n"); else printf("error: The file is not .wav format.\n"); return -1; } double *x = (double*) malloc(sizeof(double) * (x_length)); // wavread() must be called after GetAudioLength(). int fs, nbit; wavread(argv[1], &fs, &nbit, x); DisplayInformation(fs, nbit, x_length); //--------------------------------------------------------------------------- // Analysis part //--------------------------------------------------------------------------- // 2016/02/02 // A new struct is introduced to implement safe program. WorldParameters world_parameters = { 0 }; // You must set fs and frame_period before analysis/synthesis. world_parameters.fs = fs; // 5.0 ms is the default value. // Generally, the inverse of the lowest F0 of speech is the best. // However, the more elapsed time is required. world_parameters.frame_period = 5.0; // F0 estimation F0Estimation(x, x_length, &world_parameters); // Spectral envelope estimation SpectralEnvelopeEstimation(x, x_length, &world_parameters); // Aperiodicity estimation by D4C AperiodicityEstimation(x, x_length, &world_parameters); // Note that F0 must not be changed until all parameters are estimated. ParameterModification(argc, argv, fs, world_parameters.f0_length, world_parameters.fft_size, world_parameters.f0, world_parameters.spectrogram); //--------------------------------------------------------------------------- // Synthesis part //--------------------------------------------------------------------------- // The length of the output waveform int y_length = (int)((world_parameters.f0_length - 1) * world_parameters.frame_period / 1000.0 * fs) + 1; double *y = (double*) malloc(sizeof(double) * (y_length)); // Synthesis WaveformSynthesis(&world_parameters, fs, y_length, y); // Output wavwrite(y, y_length, fs, 16, argv[2]); if(y != NULL) { free(y); y = NULL; } if(x != NULL) { free(x); x = NULL; } DestroyMemory(&world_parameters); printf("complete.\n"); return 0; }
/** * Main function * */ int main(int argc, char *argv[]) { if (argc != 5) { std::cerr << argv[0] << "<input_wav_file> <output_f0_file> <output_spectrum_file> <output_aperiodicity_file>" << std::endl; return EXIT_FAILURE; } // 2016/01/28: Important modification. // Memory allocation is carried out in advanse. // This is for compatibility with C language. int x_length = GetAudioLength(argv[1]); if (x_length <= 0) { if (x_length == 0) std::cerr << "error: File \"" << argv[1] << "\" not found" << std::endl; else std::cerr << "error: File \"" << argv[1] << "\" is not a .wav format" << std::endl; return EXIT_FAILURE; } double *x = new double[x_length]; // wavread() must be called after GetAudioLength(). int fs, nbit; wavread(argv[1], &fs, &nbit, x); DisplayInformation(fs, nbit, x_length); // 2016/02/02 // A new struct is introduced to implement safe program. WorldParameters world_parameters; // You must set fs and frame_period before analysis/synthesis. world_parameters.fs = fs; // 5.0 ms is the default value. // Generally, the inverse of the lowest F0 of speech is the best. // However, the more elapsed time is required. world_parameters.frame_period = 5.0; //--------------------------------------------------------------------------- // Analysis part //--------------------------------------------------------------------------- // F0 estimation F0Estimation(x, x_length, &world_parameters); // Spectral envelope estimation SpectralEnvelopeEstimation(x, x_length, &world_parameters); // Aperiodicity estimation by D4C AperiodicityEstimation(x, x_length, &world_parameters); std::cout << "fft size = " << world_parameters.fft_size << std::endl; //--------------------------------------------------------------------------- // Saving part //--------------------------------------------------------------------------- // F0 saving std::ofstream out_f0(argv[2], std::ios::out | std::ios::binary); if(!out_f0) { std::cerr << "Cannot open file: " << argv[2] << std::endl; return EXIT_FAILURE; } out_f0.write(reinterpret_cast<const char*>(world_parameters.f0), std::streamsize(world_parameters.f0_length * sizeof(double))); out_f0.close(); // Spectrogram saving std::ofstream out_spectrogram(argv[3], std::ios::out | std::ios::binary); if(!out_spectrogram) { std::cerr << "Cannot open file: " << argv[3] << std::endl; return EXIT_FAILURE; } // write the sampling frequency out_spectrogram.write(reinterpret_cast<const char*>(&world_parameters.fs), std::streamsize( sizeof(world_parameters.fs) ) ); // write the sampling frequency out_spectrogram.write(reinterpret_cast<const char*>(&world_parameters.frame_period), std::streamsize( sizeof(world_parameters.frame_period) ) ); // write the spectrogram data for (int i=0; i<world_parameters.f0_length; i++) { out_spectrogram.write(reinterpret_cast<const char*>(world_parameters.spectrogram[i]), std::streamsize((world_parameters.fft_size / 2 + 1) * sizeof(double))); } out_spectrogram.close(); // Aperiodicity saving std::ofstream out_aperiodicity(argv[4], std::ios::out | std::ios::binary); if(!out_aperiodicity) { std::cerr << "Cannot open file: " << argv[4] << std::endl; return EXIT_FAILURE; } for (int i=0; i<world_parameters.f0_length; i++) { out_aperiodicity.write(reinterpret_cast<const char*>(world_parameters.aperiodicity[i]), std::streamsize((world_parameters.fft_size / 2 + 1) * sizeof(double))); } out_aperiodicity.close(); //--------------------------------------------------------------------------- // Cleaning part //--------------------------------------------------------------------------- delete[] x; DestroyMemory(&world_parameters); std::cout << "complete" << std::endl; return EXIT_SUCCESS; }
TST_tpRetCode TST_TestSpecific :: PerformSpecificTest( char * Command ) { // Interpret TENV Reset // AE: Reset if ( strcmp( Command , Reset_CMD ) == 0 ) { for ( int i = 0 ; i < TENV_dimVtEnv ; i++ ) { delete vtEnv[ i ] ; vtEnv[ i ] = NULL ; } /* for */ return TST_RetCodeOK ; } // end selection: Interpret TENV Reset // Test: ENV !Environment constructor // AE: NewEnvironment inxEnv else if ( strcmp( Command , ENV_MainEnvironment_002_CMD ) == 0 ) { /***** Function ENV_Environment( ) *****/ int inxEnv = -1 ; int numRead = TST_pReader->ReadCommandLine( "i" , &inxEnv ) ; if ( ( numRead != 1 ) || !VerifyInxEnv( inxEnv , NO )) { return TST_RetCodeParmError ; } /* if */ vtEnv[ inxEnv ] = new ENV_Environment( ) ; return TST_RetCodeOK ; } // end selection: Test: ENV !Environment constructor // Test: ENV !Environment destructor // AE: DeleteEnvironment inxEnv else if ( strcmp( Command , DeleteENV_003_CMD ) == 0 ) { /***** Function ~ENV_Environment( ) *****/ int inxEnv = -1 ; int numRead = TST_pReader->ReadCommandLine( "i" , &inxEnv ) ; if ( ( numRead != 1 ) || !VerifyInxEnv( inxEnv , ANY )) { return TST_RetCodeParmError ; } /* if */ delete vtEnv[ inxEnv ] ; vtEnv[ inxEnv ] = NULL ; return TST_RetCodeOK ; } // end selection: Test: ENV !Environment destructor // Test: ENV !Build environment // AE: BuildEnvironment inxEnvironment environmentVarName // if environmentVarName == "." builds with NULL else if ( strcmp( Command , BuildEnvironment_004_CMD ) == 0 ) { struct PointerEnvelope { MSG_Message * pMsg ; STR_String * pStr ; PointerEnvelope( ) { pMsg = NULL ; pStr = NULL ; } ~PointerEnvelope( ) { delete pMsg ; delete pStr ; } } envelope ; /* struct */ /***** Function void BuildEnvironment( char * environmentVarName ) *****/ int inxEnv = -1 ; int sizValue = -1 ; char Value[ TAL_dimBuffer ] ; int numRead = TST_pReader->ReadCommandLine( "is" , &inxEnv , &sizValue , Value ) ; if ( ( numRead != 2 ) || !VerifyInxEnv( inxEnv , YES )) { return TST_RetCodeParmError ; } /* if */ if ( strcmp( Value , "." ) != 0 ) { envelope.pMsg = vtEnv[ inxEnv ]->BuildEnvironment( Value ) ; } else { envelope.pMsg = vtEnv[ inxEnv ]->BuildEnvironment( NULL ) ; } /* if */ if ( envelope.pMsg != NULL ) { envelope.pStr = envelope.pMsg->AssembleMessage( ) ; DisplayErrorMsg( envelope.pStr->GetString( )) ; return TST_RetCodeFailure ; } /* if */ return TST_RetCodeOK ; } // end selection: Test: ENV !Build environment // Test: ENV !Set environment empty // AE: SetEmpty inxEnvironment else if ( strcmp( Command , SetEmpty_005_CMD ) == 0 ) { /***** Function void SetEmpty( ) *****/ int inxEnv = -1 ; int numRead = TST_pReader->ReadCommandLine( "i" , &inxEnv ) ; if ( ( numRead != 1 ) || !VerifyInxEnv( inxEnv , YES )) { return TST_RetCodeParmError ; } /* if */ vtEnv[ inxEnv ]->SetEmpty( ) ; return TST_RetCodeOK ; } // end selection: Test: ENV !Set environment empty // Test: ENV !Get environment variable // AE: GetVariableName inxEnvironment expName // expName == "." displays the name // expName == "" expects NULL name else if ( strcmp( Command , GetVariable_006_CMD ) == 0 ) { struct PointerEnvelope { STR_String * pStr ; PointerEnvelope( ) { pStr = NULL ; } ~PointerEnvelope( ) { delete pStr ; } } envelope ; /* struct */ /***** Function STR_String * GetVariable( ) *****/ int inxEnv = -1 ; int sizValue = -1 ; char Value[ TAL_dimBuffer ] ; int numRead = TST_pReader->ReadCommandLine( "is" , &inxEnv , &sizValue , Value ) ; if ( ( numRead != 2 ) || !VerifyInxEnv( inxEnv , YES )) { return TST_RetCodeParmError ; } /* if */ envelope.pStr = vtEnv[ inxEnv ]->GetVariable( ) ; if ( strcmp( Value , "." ) != 0 ) { if ( envelope.pStr != NULL ) { return Compare( envelope.pStr->GetLength( ) , envelope.pStr->GetString( ) , sizValue , Value , "Incorrect environment variable name" ) ; } /* if */ if ( strcmp( Value , "" ) != 0 ) { return TST_RetCodeOK ; } /* if */ DisplayErrorMsg( "Variable is NULL." ) ; return TST_RetCodeFailure ; } /* if */ if ( envelope.pStr != NULL ) { DisplayInformation( "Environment variable name: " , envelope.pStr->GetString( )) ; } else { DisplayInformation( "Variable is not set." , "" ) ; } /* if */ return TST_RetCodeOK ; } // end selection: Test: ENV !Get environment variable // Test: ENV !Get environment string // AE: GetEnvironmentString inxEnvironment expString // expString == "." displays the string // expString == "" expects NULL string else if ( strcmp( Command , GetString_007_CMD ) == 0 ) { struct PointerEnvelope { STR_String * pStr ; PointerEnvelope( ) { pStr = NULL ; } ~PointerEnvelope( ) { delete pStr ; } } envelope ; /* struct */ /***** Function STR_String * GetString( ) *****/ int inxEnv = -1 ; int sizValue = -1 ; char Value[ TAL_dimBuffer ] ; int numRead = TST_pReader->ReadCommandLine( "is" , &inxEnv , &sizValue , Value ) ; if ( ( numRead != 2 ) || !VerifyInxEnv( inxEnv , YES )) { return TST_RetCodeParmError ; } /* if */ envelope.pStr = vtEnv[ inxEnv ]->GetString( ) ; if ( strcmp( Value , "." ) != 0 ) { if ( envelope.pStr != NULL ) { return Compare( envelope.pStr->GetLength( ) , envelope.pStr->GetString( ) , sizValue , Value , "Incorrect environment variable string" ) ; } /* if */ if ( strcmp( Value , "" ) != 0 ) { return TST_RetCodeOK ; } /* if */ DisplayErrorMsg( "String is NULL." ) ; return TST_RetCodeFailure ; } /* if */ if ( envelope.pStr != NULL ) { DisplayInformation( "Environment variable string: " , envelope.pStr->GetString( )) ; } else { DisplayInformation( "String is NULL." , "" ) ; } /* if */ return TST_RetCodeOK ; } // end selection: Test: ENV !Get environment string // Test: ENV !Get environment parameter // AE: GetParameter inxEnvironment parameterName expValue else if ( strcmp( Command , GetParameter_008_CMD ) == 0 ) { struct PointerEnvelope { STR_String * pStr ; PointerEnvelope( ) { pStr = NULL ; } ~PointerEnvelope( ) { delete pStr ; } } envelope ; /* struct */ /***** Function STR_String * GetParameter( char * parameterName ) *****/ int inxEnv = -1 ; int sizParmName = -1 ; char parmName[ TAL_dimBuffer ] ; int sizValue = -1 ; char Value[ TAL_dimBuffer ] ; int numRead = TST_pReader->ReadCommandLine( "iss" , &inxEnv , &sizParmName , parmName , &sizValue , Value ) ; if ( ( numRead != 3 ) || !VerifyInxEnv( inxEnv , YES )) { return TST_RetCodeParmError ; } /* if */ envelope.pStr = vtEnv[ inxEnv ]->GetParameter( parmName ) ; if ( strcmp( Value , "." ) != 0 ) { if ( envelope.pStr != NULL ) { return Compare( envelope.pStr->GetLength( ) , envelope.pStr->GetString( ) , sizValue , Value , "Incorrect environment parameter value." ) ; } /* if */ DisplayErrorMsg( "Did not find parameter: " , parmName ) ; return TST_RetCodeFailure ; } /* if */ if ( envelope.pStr != NULL ) { DisplayInformation( "Environment parameter: " , envelope.pStr->GetString( )) ; } else { DisplayInformation( "Did not find parameter: " , parmName ) ; } /* if */ return TST_RetCodeOK ; } // end selection: Test: ENV !Get environment parameter return TST_RetCodeUnknown ; } // End of function: TENV !P Perform specific test actions