private void determineProsodicSettings(Element prosody){
  ProsodicSettings settings=new ProsodicSettings();
  ProsodicSettings parentSettings=new ProsodicSettings();
  Element ancestor=(Element)DomUtils.getAncestor(prosody,MaryXML.PROSODY);
  if (ancestor != null) {
    ProsodicSettings testSettings=prosodyMap.get(ancestor);
    if (testSettings != null) {
      parentSettings=testSettings;
    }
  }
  settings.setRate(parentSettings.rate() + MaryUtils.getPercentageDelta(prosody.getAttribute("rate")));
  settings.setAccentProminence(parentSettings.accentProminence() + MaryUtils.getPercentageDelta(prosody.getAttribute("accent-prominence")));
  settings.setAccentSlope(parentSettings.accentSlope() + MaryUtils.getPercentageDelta(prosody.getAttribute("accent-slope")));
  settings.setNumberOfPauses(parentSettings.numberOfPauses() + MaryUtils.getPercentageDelta(prosody.getAttribute("number-of-pauses")));
  settings.setPauseDuration(parentSettings.pauseDuration() + MaryUtils.getPercentageDelta(prosody.getAttribute("pause-duration")));
  settings.setVowelDuration(parentSettings.vowelDuration() + MaryUtils.getPercentageDelta(prosody.getAttribute("vowel-duration")));
  settings.setPlosiveDuration(parentSettings.plosiveDuration() + MaryUtils.getPercentageDelta(prosody.getAttribute("plosive-duration")));
  settings.setFricativeDuration(parentSettings.fricativeDuration() + MaryUtils.getPercentageDelta(prosody.getAttribute("fricative-duration")));
  settings.setNasalDuration(parentSettings.nasalDuration() + MaryUtils.getPercentageDelta(prosody.getAttribute("nasal-duration")));
  settings.setLiquidDuration(parentSettings.liquidDuration() + MaryUtils.getPercentageDelta(prosody.getAttribute("liquid-duration")));
  settings.setGlideDuration(parentSettings.glideDuration() + MaryUtils.getPercentageDelta(prosody.getAttribute("glide-duration")));
  String sVolume=prosody.getAttribute("volume");
  if (sVolume.equals("")) {
    settings.setVolume(parentSettings.volume());
  }
 else   if (MaryUtils.isPercentageDelta(sVolume)) {
    int newVolume=parentSettings.volume() + MaryUtils.getPercentageDelta(sVolume);
    if (newVolume < 0)     newVolume=0;
 else     if (newVolume > 100)     newVolume=100;
    settings.setVolume(newVolume);
  }
 else   if (MaryUtils.isUnsignedNumber(sVolume)) {
    settings.setVolume(MaryUtils.getUnsignedNumber(sVolume));
  }
 else   if (sVolume.equals("silent")) {
    settings.setVolume(0);
  }
 else   if (sVolume.equals("soft")) {
    settings.setVolume(25);
  }
 else   if (sVolume.equals("medium")) {
    settings.setVolume(50);
  }
 else   if (sVolume.equals("loud")) {
    settings.setVolume(75);
  }
  prosodyMap.put(prosody,settings);
}

private void determineProsodicSettings ( Element prosody ) { ProsodicSettings settings = new ProsodicSettings ( ) ; ProsodicSettings parentSettings = new ProsodicSettings ( ) ; Element ancestor = ( Element ) DomUtils . getAncestor ( prosody , MaryXML . PROSODY ) ; if ( ancestor != null ) { ProsodicSettings testSettings = prosodyMap . get ( ancestor ) ; if ( testSettings != null ) { parentSettings = testSettings ; } } settings . setRate ( parentSettings . rate ( ) + MaryUtils . getPercentageDelta ( prosody . getAttribute ( "rate" ) ) ) ; settings . setAccentProminence ( parentSettings . accentProminence ( ) + MaryUtils . getPercentageDelta ( prosody . getAttribute ( "accent-prominence" ) ) ) ; settings . setAccentSlope ( parentSettings . accentSlope ( ) + MaryUtils . getPercentageDelta ( prosody . getAttribute ( "accent-slope" ) ) ) ; settings . setNumberOfPauses ( parentSettings . numberOfPauses ( ) + MaryUtils . getPercentageDelta ( prosody . getAttribute ( "number-of-pauses" ) ) ) ; settings . setPauseDuration ( parentSettings . pauseDuration ( ) + MaryUtils . getPercentageDelta ( prosody . getAttribute ( "pause-duration" ) ) ) ; settings . setVowelDuration ( parentSettings . vowelDuration ( ) + MaryUtils . getPercentageDelta ( prosody . getAttribute ( "vowel-duration" ) ) ) ; settings . setPlosiveDuration ( parentSettings . plosiveDuration ( ) + MaryUtils . getPercentageDelta ( prosody . getAttribute ( "plosive-duration" ) ) ) ; settings . setFricativeDuration ( parentSettings . fricativeDuration ( ) + MaryUtils . getPercentageDelta ( prosody . getAttribute ( "fricative-duration" ) ) ) ; settings . setNasalDuration ( parentSettings . nasalDuration ( ) + MaryUtils . getPercentageDelta ( prosody . getAttribute ( "nasal-duration" ) ) ) ; settings . setLiquidDuration ( parentSettings . liquidDuration ( ) + MaryUtils . getPercentageDelta ( prosody . getAttribute ( "liquid-duration" ) ) ) ; settings . setGlideDuration ( parentSettings . glideDuration ( ) + MaryUtils . getPercentageDelta ( prosody . getAttribute ( "glide-duration" ) ) ) ; String sVolume = prosody . getAttribute ( "volume" ) ; if ( sVolume . equals ( "" ) ) { settings . setVolume ( parentSettings . volume ( ) ) ; } else if ( MaryUtils . isPercentageDelta ( sVolume ) ) { int newVolume = parentSettings . volume ( ) + MaryUtils . getPercentageDelta ( sVolume ) ; if ( newVolume < 0 ) newVolume = 0 ; else if ( newVolume > 100 ) newVolume = 100 ; settings . setVolume ( newVolume ) ; } else if ( MaryUtils . isUnsignedNumber ( sVolume ) ) { settings . setVolume ( MaryUtils . getUnsignedNumber ( sVolume ) ) ; } else if ( sVolume . equals ( "silent" ) ) { settings . setVolume ( 0 ) ; } else if ( sVolume . equals ( "soft" ) ) { settings . setVolume ( 25 ) ; } else if ( sVolume . equals ( "medium" ) ) { settings . setVolume ( 50 ) ; } else if ( sVolume . equals ( "loud" ) ) { settings . setVolume ( 75 ) ; } prosodyMap . put ( prosody , settings ) ; }
for one given prosody element , determine the prosodic settings , taking into account its closest prosody ancestor ' s settings . this method needs to be called once when starting to work with a document ( from determineprosodicsettings ( document ) and when a new prosody element is created ( e . g . for upstep / downstep ) .
