Search code examples
actionscript-3flashaudio

AS3 SoundChannel/Sound HZ Limit for importing


I have wav files that are at 1411kbs bit rate and varying frequencies. After I import them into the library and give them unique classes based on their frequency and other information (that is why I use getDefinitionByName below).

All of my wav files play fine in AS3 that are under 6000hz and 8000hz, however those tones don't play properly. However, they do play properly when clicking the Play icon when in Flash Adobe Animate.

I have stripped my code down to the bare essentials to see where the problem lies and still not working properly.

My question is, is there a problem with my code or does AS3/Flash have a limit on the frequency it can play?

var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();

btn.addEventListener(MouseEvent.CLICK, function(){
    var sound_class = "L6000_0";

    var soundTX:SoundTransform = myChannel.soundTransform;
    soundTX.leftToLeft = 1;
    soundTX.leftToRight = 0;
    soundTX.volume = 1;
    soundTX.rightToRight = 0;
    soundTX.rightToLeft = 0;
    var sclass:Class = getDefinitionByName(sound_class) as Class;
    var mySound:Sound = new sclass;

    myChannel.stop();
    myChannel = mySound.play();
    myChannel.soundTransform = soundTX;
});

Solution

  • It is not the scripting problem, I think. By default Flash exports sounds at very low bitrate and quality. Go to each sound properties to set the export settings or, alternately, in File > Publish Settings screen there's an option about exporting sounds.