sound tips
ASaudio&SoundAS 两个开源项目阅读:
ASaudio&SoundAS 都是比较小巧的声音控制,但似乎都不能直接拿到项目只直接使用。
ASaudio
ASaudio的Track,Group和Tween的TweenCore SimpleTimeline有些类似,但相对简单点。
它的音量控制是也是通过enterFrame+getTimer实现的。
但项目中已经有了通过的enterFrame,如果直接使用的话,会有些浪费,需要嵌入到项目中才比较好。
另外ASaudio也是在enterFrame中监听audio是否播放完成,进而抛出事件的。这个避免了原生的sound在播放完成时可能存在的bug。
这个bug是 在播放完一段声音时soundchannel.position 和 sound.length的值有差距。测试结果:soundchannel.position< sound.length
SoundAS
SoundAS相对来说更实用一点。它引用了Signal类库,如果在项目中采用的话,要么也同时引起该类库,要么再做修改。工作量一样很大。
对于同一个url,SoundAS做了缓存处理,不会new一个sound,这点比ASaudio好。
SoundAS的代码注释中还提供的一个channel bug,url地址:http://www.stevensacks.net/2008/08/07/as3-sound-channel-bug/
这个bug时,如果循环播放一段声音,通过channel.position得到的位置可能是超出声音长度,当你使用这个位置数据调用play方法时就会报错。
原文如下:
I don't know if this has been documented or not.
If you set a Sound to loop, it's channel.position property returns a number out of range of the Sound.length after it loops. The position property just keeps on incrementing beyond the length when you loop a sound.
If you try to play a Sound from that out of range position, the Sound glitches out, because that position is invalid, even though Flash returns it to you, implying it's valid. Flash should not return an invalid position to you.
This all revolves around the fact that Sound has absolutely no way to pause right now. I don't know why Adobe did not give us a channel.pause() method. Because they chose not to, this bug has bad consequences.
The only way to pause and unpause a sound in Flash is to store the current position of the channel and call channel.stop(), and when you unpause, you call sound.play(position). This works fine if you're only playing the sound once. If you're looping, however, it doesn't at all.
If the sound is looping, the position returned will eventually be higher than the length, which means the Sound glitches because you're passing an out of range position; a position, once again, that Flash returned to you as valid.
Wait, it gets worse. If you unpause a looping sound by passing its position, when it loops, it will loop from that position, not the beginning of the Sound. Problem!
There is no pause method for channel, and without a pause method, there is no workaround for the above bug and issue except to manually loop a Sound by adding an event listener to the sound complete event (which can be unreliable), calling play on it again and managing the looping manually, which undermines the loops argument of the Sound.play() method and requires a fair amount of code.
Adobe, we need a channel.pause(flag:Boolean) method.
sound tips的更多相关文章
- android 官方文档 JNI TIPS
文章地址 http://developer.android.com/training/articles/perf-jni.html JNI Tips JNI is the Java Native I ...
- English Phrases with THE – Linking the TH Sound
English Phrases with THE – Linking the TH Sound Share Tweet Share Tagged With: The Word THE Study En ...
- Learn English like a Baby – How to Sound Native
Learn English like a Baby – How to Sound Native Share Tweet Share Tagged With: tips & tricks Wha ...
- Productivity tips, tricks and hacks for academics (2015 edition)
Productivity tips, tricks and hacks for academics (2015 edition) Contents Jump to: My philosophy: Op ...
- (Forward)5 Public Speaking Tips That'll Prepare You for Any Interview
Landing a job interview is incredibly exciting –- and often terrifying. But fear not. There are clev ...
- 10 Essential TypeScript Tips And Tricks For Angular Devs
原文: https://www.sitepoint.com/10-essential-typescript-tips-tricks-angular/ ------------------------- ...
- Android 性能优化(18)JNI优化:JNI Tips 提升性能技巧
JNI Tips 1.In this document JavaVM and JNIEnv Threads jclass, jmethodID, and jfieldID Local and Glob ...
- Direction of Arrival Based Spatial Covariance Model for Blind Sound Source Separation
基于信号协方差模型DOA的盲声源分离[1]. 在此基础上,作者团队于2018年又发布了一篇文章,采用分级和时间差的空间协方差模型及非负矩阵分解的多通道盲声源分离[2]. 摘要 本文通过对短时傅立叶变换 ...
- Mac上MySQL忘记root密码且没有权限的处理办法&workbench的一些tips (转)
忘记Root密码肿么办 Mac上安装MySQL就不多说了,去mysql的官网上下载最新的mysql包以及workbench,先安装哪个影响都不大.如果你是第一次安装,在mysql安装完成之后,会弹出来 ...
随机推荐
- java EE 5 Libraries 删掉后怎么重新导入
(1)Add Library 中 MyEclipse Libraries (2)输入 java 即可找到 问题解决.
- 数据库(.udl)简单测试连接
当我们烦于打开数据库进行连接的时候,我们可以用udl进行测试连接,并可以获得连接字符串. 1.新建一个txt文件,然后将后缀改成udl保存. 2.双击打开udl文件. 3.进行数据库连接测试. 4.用 ...
- UVA 12373 Pair of Touching Circles
思路:(注意2个圆的半径可以不一样) 有2种情况: 1) 水平和竖直放.这种情况很简单,刚开始以为只有这种情况,但是样例5不对,后来知道还有一种情况. 2)斜线也可以放.只要满足勾股数就可以.现在的问 ...
- LINUX输入输出与文件
1 文件描述符 内核为每个进程维护一个已打开文件的记录表(实现为结构体数组),文件描述符是一个较小的正整数(0-1023)(结构体数组下标),它代表记录表的一项,通过文件描述符和一组基于文件描述符的文 ...
- VISO下载地址
http://pan.baidu.com/share/home?uk=4011207371#category/type=0
- Spring学习总结(1)——Spring AOP的概念理解
1.我所知道的aop 初看aop,上来就是一大堆术语,而且还有个拉风的名字,面向切面编程,都说是OOP的一种有益补充等等.一下子让你不知所措,心想着:怪不得 很多人都和我说aop多难多难 .当我看进去 ...
- java多线程理解2
1. 什么时候必须同步?什么叫同步?如何同步? 要跨线程维护正确的可见性,只要在几个线程之间共享非 final 变量,就必须使用 synchronized(或 volatile)以确保一个线程可以看见 ...
- CSS3:empty
:empty ---空的元素样式 <!DOCTYPE html> <html> <head lang="en"> <meta charse ...
- jQuery RemoveAttr(checked)之后再Attr(checked)属性无效果的原因分析
jQuery中attr()和prop()在修改checked属性时的区别 投稿:whsnow 字体:[增加 减小] 类型:转载 使用语句$.attr('checked',true),将复选框的属性 ...
- poj - 3268 Silver Cow Party (求给定两点之间的最短路)
http://poj.org/problem?id=3268 每头牛都要去标号为X的农场参加一个party,农场总共有N个(标号为1-n),总共有M单向路联通,每头牛参加完party之后需要返回自己的 ...