English 中文(简体)
利用AS3WavSound玩弄WAV,不能立即停止。
原标题:Using AS3WavSound to play WAV - cannot stop instantly

I m using the AS3WavSound (http://code.google.com/p/as3wavsound/) class to playback externally loaded wavs. This is working successfully. The library is simple and effective.

在对Wav ByteArray进行脱节之后,图书馆利用SampleDataEvent进行回击。 SAMPLE_DATA活动,然后将混合样本写到产出流。

player.addEventListener(SampleDataEvent.SAMPLE_DATA, onSamplesCallback);
private function onSamplesCallback( evt : SampleDataEvent ):void
{
    for (var i:int = 0; i < samplesLength; i++) 
    {
        if(_mute ==  false){
           outputStream.writeFloat(samplesLeft[i]);
           outputStream.writeFloat(samplesRight[i]);
        }   
    }
}

我的问题是,我必须立即保持这一音响产出的沉默,但无论我所尝试的任何方法,在沉默生效之前,都出现了明显的拖延(1次快乐)。

各位可以看到,我曾试图增加一只ool子,以阻挡在产出流上书写的任何样本,但这对拖延没有影响。

我怀疑,这是样品缓冲和随后书写的基本内容。 基本上到用户在屏幕上采取行动时(浮出 mu子),而 _鱼的真面貌已经确定,有些样本已经等待书写,无法受到影响。

对我怀疑的任何建议或确认将受到高度赞赏。

Thanks, gfte.

问题回答

Your suspicion is probably right - but why stop it at that level? If you want to turn off the sound, would it not be better to set the volume on the soundTransform-property on the SoundChannel-object returned by the play method? (I assume the wav library returns this in some way)

它像你使用的图书馆一样,也使用与本土的闪电灯光灯光灯类似的设计,在这种设计中,从游戏法中回收了音障。 这种“智障”方法应当停止正确的权利。

var sound:WavSoundPlayer = new WavSoundPlayer();
var channel:WavSoundChannel = new WavSoundChannel();

sound.addEventListener( SampleDataEvent.SAMPLE_DATA, onSampleData );
channel = sound.play();

    private function onSamplesData( evt : SampleDataEvent ):void
    {
        for (var i:int = 0; i < samplesLength; i++) 
        {
           outputStream.writeFloat(samplesLeft[i]);
           outputStream.writeFloat(samplesRight[i]);   
        }
    }

    channel.stop()

The _mute variable in your example will only be able to change either before or after the loop, not while it is looping.





相关问题
Playing a Sound With Monotouch

No matter what I try (build -> content, NSUrl, filename) I get a null exception : file not found when I try to play a .caf sound file in monotouch. //var path = NSBundle.MainBundle.PathForResource("...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

Play sound in iPhone web app with Javascript?

I m currently creating an iPhone web application for piano chords, and I wanted to add an option that would let the user press a Play button and play the selected chord. However, I m not sure how to ...

热门标签