/**
* 慢速播放( 音调变沉闷 )
* @param ais
* @param player
* @throws IOException
*/
private static void handleCase2_slow_muffled(AudioInputStream ais, SourceDataLine player ) throws IOException {
System.out.println( "case2:" );
int len;
byte[] buf = new byte[4];
int i=0;
long t = System.currentTimeMillis();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
while((len=ais.read(buf))!=-1) {
i++;
if( i < 2152526 ){
continue;
}
if( i >= 3360000 ){
break;
}
// 实现变慢,但是调不变粗
//左声道
buf[1] = ( byte ) ( buf[1] );
//右声道
buf[3] = ( byte ) ( buf[3] );
player.write(buf, 0, len);
if( i % 2 == 0 ){
//左声道
buf[1] = 0;
//右声道
buf[3] = 0;
player.write(buf, 0, len);
}
}
}
The principle is to play a sample and fill a 0 sample (the purpose of filling is to slow down the playback speed). When the sound is slowed down, the timbre also changes and becomes very dull, like a monster. Generally, it is used as a monster sound effect