MoreSounds

MoreSounds -...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/************************************ INCREASE VOLUME *************************************/ public void increaseVolume() { SoundSample[] sampleArray = this.getSamples; SoundSample sample = null; int value = 0; int index = 0; while(index < sampleArray.length) { sample = sampleArray[index]; value = sample.getValue(); sample.setValue(value * 2); index++; } } /************************************ NORMALIZE *************************************/ public void normalize(int largestSoundValue) { int largest = 0; int maxIndex = 0; SoundSample [] sampleArray = this.getSamples(); SoundSample sample = null; int value = 0; for(int i = 0; i < sampleArray.length; i++) { sample = sampleArray[i]; value = Math.abs(sample.getValue()); if(value > largest) { largest = value; maxIndex = i; } } double multiplier = largestSoundValue / largest; for(int i = 0; i < sampleArray.length; i++) { sample = sampleArray[i]; sample.setValue((int)(sample.getValue() * multiplier)); } } /************************************ CLIP
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

MoreSounds -...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online