int main() { boost::tuple<char, int, char, int> decim('-', 10, 'e', 5); assert(stringize(decim) == "-10e5"); std::pair<short, std::string> value_and_type(270, "Kelvin"); assert(stringize(value_and_type) == "270Kelvin"); }
float vtt_sim( void ) { int i, j, time, r_arm; double p, q, sound, sound_decim; /*** compute da and dx with a new area function, and Ud=d(A*x)/dt ***/ dax(); /*** Simulate deci (=simfrq/smpfrq) cycles with interpolation of a and x ***/ for(time=0; time<deci; time++) { /*** refresh area function by a linear interpolation ***/ afglt[0].A = nonzero_t(afglt[0].A + dafglt[0].A); /* glottis */ if(vocal_tract == TIME_VARYING) refresh_af(); /*** time-varying acoustic elements ***/ acous_elements_t(GLOTTIS, nglt0, afglt, acglt); if(vocal_tract == TIME_VARYING) refresh_acoustic_elements(); /*** Bernoulli (kinetic) resistance at glottis and at constriction ***/ /* compute a DC flow considering flow resistances at the 2 constrictions */ Rg_v = acglt[0].Rs + acglt[1].Rs; Ag2 = 1./(afglt[0].A*afglt[0].A); Ac2 = 1./(Ac.A*Ac.A); Rc_v = 2.*K_viscous_const*Ac.x*Ac2; rv_sum = Rg_v + Rc_v; rk_sum = K_Bernoulli*(Ag2 + Ac2); Udc = (-rv_sum + sqrt(rv_sum*rv_sum + 4.*rk_sum*H2O_bar*Psub)) /(2.*rk_sum); Rg_k = K_Bernoulli*Udc*Ag2; Rc_k = K_Bernoulli*Udc*Ac2; acglt[1].Rs += Rg_k; /* add Bernoulli res. to glottis */ if(Ac.Loc == PHARYNX) ac[Ac.N+1].Rs = Rc_v + Rc_k; if(Ac.Loc == MOUTH) acbu[Ac.N+1].Rs = Rc_v + Rc_k; /* Noise sources at the exit of glottis and at the constriction */ if(noise_source == ON) { if(Ac.Loc == PHARYNX) { j = Ac.N+noiseSourceLoc+1; /* at n sections downstream */ if(j > nvt0)j = Ac.N + 1; /* at the exit */ ac[j].Ns = noiseAmp *frictionNoise3(1, inMemAc, outMemAc, &lowMemAc) *(Udc*Udc*Udc/pow(Ac.A, 2.5)); } if(Ac.Loc == MOUTH) { j = Ac.N+noiseSourceLoc+1; /* at n sections downstream */ if(j > nbu0)j = Ac.N + 1; /* at the exit */ acbu[j].Ns = noiseAmp *frictionNoise3(1, inMemAc, outMemAc, &lowMemAc) *(Udc*Udc*Udc/pow(Ac.A, 2.5)); } /* -10dB = 0.315, -16dB = 0.158, -20dB = 0.1 */ acglt[1].Ns = 0.1*noiseAmp *frictionNoise3(1, inMemGlt, outMemGlt, &lowMemGlt) *(Udc*Udc*Udc/pow(afglt[0].A, 2.5)); } /*** w : matrix elements ***/ /* vocal tract : {trachea} + glottis + pharynx + {mouth} */ r_arm = 1; if(subGLTsystem == ON) { eq_elements_t(TRACHEA, &r_arm, ntr, actr, eq); eq[1].w += Rlungs; } eq_elements_t(GLOTTIS, &r_arm, nglt0, acglt, eq); if(subGLTsystem == OFF) eq[1].w += Rlungs; eq_elements_t(VOCAL_TRACT, &r_arm, nvt0, ac, eq); if(nasal_tract == ON) { /* bucal and nasal tract */ r_arm = 1; eq_elements_t(VOCAL_TRACT, &r_arm, nbu0, acbu, eqbu); r_arm = 1; eq_elements_t(NOSE, &r_arm, nnc, acnc, eqnt); eq_elements_t(NOSE, &r_arm, nna0, acna, eqnt); } /*** Refresh force constants ***/ U1_wall = 0; /* initialization for total wall "flow" */ /* vocal tract : {trachea} + glottis + pharynx + {mouth} */ r_arm = 1; if(subGLTsystem == ON) force_constants(TRACHEA, &r_arm, ntr, actr, eq); force_constants(GLOTTIS, &r_arm, nglt0, acglt, eq); force_constants(VOCAL_TRACT, &r_arm, nvt0, ac, eq); if(nasal_tract == OFF && rad_boundary == RL_CIRCUIT ) { iLrad_lip = 2.0*Lrad_lip*eq[n4].x + iLrad_lip; eq[n4].s = -iLrad_lip; /* rad. admitance */ } if( nasal_tract == ON ) { r_arm = 1; force_constants(VOCAL_TRACT, &r_arm, nbu0, acbu, eqbu); if( rad_boundary == RL_CIRCUIT ) { iLrad_lip = 2.0*Lrad_lip*eqbu[nbu4].x + iLrad_lip; eqbu[nbu4].s = -iLrad_lip; /* rad. admitance */ } r_arm = 1; force_constants(NOSE, &r_arm, nnc, acnc, eqnt); force_constants(NOSE, &r_arm, nna0, acna, eqnt); if( rad_boundary == RL_CIRCUIT ) { iLrad_nos = 2.0*Lrad_nos*eqnt[nnt4].x + iLrad_nos; eqnt[nnt4].s = -iLrad_nos; /* rad. admitance */ } } /*** solve s = Wx ***/ if(nasal_tract == OFF) { forward_elimination_t(n4, eq); eq[n4].x = eq[n4].S/eq[n4].W; backward_substitution_t(n3, eq); } else { forward_elimination_t(n3, eq); backward_elimination_t(nbu4, eqbu); backward_elimination_t(nnt4, eqnt); p = eq[n3].S/eq[n3].W-eqbu[1].S/eqbu[1].W-eqnt[1].S/eqnt[1].W; q = eq[n2].W/eq[n3].W+eqbu[2].W/eqbu[1].W+eqnt[2].W/eqnt[1].W; eq[n4].x = eqbu[0].x = eqnt[0].x = p/q; backward_substitution_t(n3, eq); forward_substitution_t(nbu4, eqbu); forward_substitution_t(nnt4, eqnt); } /* decimation of the radiated sound */ U0_lip = U1_lip; if(nasal_tract == OFF) U1_lip = -eq[n3].x; else U1_lip = -eqbu[nbu3].x; sound = U1_lip - U0_lip; if(wall_radiation == ON) { sound += (U1_wall - U0_wall); /* radiation from walls */ U0_wall = U1_wall; } if(nasal_tract == ON) { U0_nos = U1_nos; /* add radiation from nose */ U1_nos = -eqnt[nnt3].x; sound += (U1_nos - U0_nos); } if( time == deci - 1 ) sound_decim = decim( 1, Kr*sound ); else decim( 0, Kr*sound ); } /* sample Ug and Uac at fixed points, 1st and nAcc-th section */ j = 1; if(subGLTsystem==ON) j += ntr; j = 2*j + 1; Ug = eq[j].x; if(nasal_tract==OFF) { j = nAcc + 1; if(subGLTsystem==ON) j += ntr; j = 2*j + 1; Uac = eq[j].x; } else { if(nAcc <= nbp) { j = nAcc + 1; if(subGLTsystem==ON) j+=ntr; j = 2*j + 1; Uac = eq[j].x; } else { j = 2*nAcc + 1; Uac = eqbu[j].x; } } return(sound_decim); }
float vtt_sim( void ) { int j; float f, g, h, p, q, sound, sound_decim; /*** compute da and dx with a new area function, and Ud=d(A*x)/dt ***/ if( vocal_tract == TIME_VARYING) { dax(); if( dynamic_term == ON ) Ud(); } /*** Simulate deci (=simfrq/smpfrq) cycles with interpolation of a and x ***/ for(j=0; j<deci; j++) { /*** solve s = Wx ***/ if( nasal_tract == ON ) { elimination_t(1, nph3, eqph); elimination_t(0, nbu3, eqbu); elimination_t(0, nna3, eqna); f = eqph[nph3].S/eqph[nph3].W; g = eqbu[nbu3].S/eqbu[nbu3].W; h = eqna[nna3].S/eqna[nna3].W; p = f + g + h; f = eqph[nph2].W/eqph[nph3].W; g = eqbu[nbu2].W/eqbu[nbu3].W; h = eqna[nna2].W/eqna[nna3].W; q = f + g + h; eqph[nph4].x = eqbu[nbu4].x = eqna[nna4].x = p/q; substitution_t(1, nph3, eqph); substitution_t(0, nbu3, eqbu); substitution_t(0, nna3, eqna); } else { elimination_t(1, nph3, eqph); elimination_t(0, nbu3, eqbu); f = eqph[nph3].S/eqph[nph3].W; g = eqbu[nbu3].S/eqbu[nbu3].W; p = f + g; f = eqph[nph2].W/eqph[nph3].W; g = eqbu[nbu2].W/eqbu[nbu3].W; q = f + g; eqph[nph4].x = eqbu[nbu4].x = p/q; substitution_t(1, nph3, eqph); substitution_t(0, nbu3, eqbu); } /*** Refresh acoustic and matrix elements ***/ if( vocal_tract == TIME_VARYING ) { /* pharyngeal tract */ acou_mtrx( nph, afph, dph, acph, eqph, 0., 0.); /* bucal cavity */ acou_mtrx( nbu, afbu, dbu, acbu, eqbu, 0., 0.); if( rad_boundary == RL_CIRCUIT ) { Grad_lips = Grad*afbu[0].A; Lrad_lips = (float)(Srad*sqrt(afbu[0].A)); eqbu[0].w = Grad_lips + Lrad_lips; } else eqbu[0].w = 10.0; /* short circuit */ /* nasal inlet */ acou_mtrx(1, afnc, dnc, acna+nna-1, eqna+2*(nna-1), Rs_na, Ls_na); } /* add the glottal resistance (it alwalys time_varying) */ Ag = nonzero_t( Ag ); eqph[1].w = (float)(acph[0].Rs + acph[0].Ls + (Rv*xg/Ag + Rk*fabs(eqph[1].x))/(Ag*Ag)); /*** Refresh force constants ***/ force_constants(nph, acph, eqph); eqph[1].s = acph[0].els + H2O_bar*Psub; /* right arm */ if( rad_boundary == RL_CIRCUIT ) irad_lips = (float)(2.0*Lrad_lips*eqbu[0].x + irad_lips); force_constants(nbu, acbu, eqbu); eqbu[0].s = -irad_lips; /* rad. admitance */ eqbu[1].s = acbu[0].els; /* right arm */ U0_lips = U1_lips; U1_lips = -eqbu[1].x; sound = U1_lips - U0_lips; if( nasal_tract == ON ) { if( rad_boundary == RL_CIRCUIT ) irad_nose = (float)(2.0*Lrad_nose*eqna[0].x + irad_nose); force_constants(nna, acna, eqna); eqna[0].s = -irad_nose; /* rad. admitance */ eqna[1].s = acna[0].els; /* right arm */ U0_nose = U1_nose; U1_nose = -eqna[1].x; sound = sound + U1_nose - U0_nose; } /*** decimation of the radiated sound ***/ if( j == deci - 1 ) sound_decim = decim( 1, Kr*sound ); else decim( 0, Kr*sound ); } /*** return the radiated sound pressure ***/ return( sound_decim ); }