通过 Actionscript 3 引用时间轴上现有的声音对象
在 Actionscript 3 / Flash 10 中,是否可以以编程方式引用时间轴上存在的声音对象?我发现了很多通过以下语法引用 DisplayObjects 的示例:
var m:MovieClip = stage.getChildByName("SomeMovieClipClass");
var n:MovieClip = stage.getChildByIndex(1);
但这似乎不包括声音对象。同样,通过 Actionscript 实例化和播放库中存在的声音似乎很简单:
var s:SoundClip1 = new SoundClip1(); // exported in first frame via properties
s.play();
不过,出于我的目的,我想引用声音剪辑(理想情况下在特定层中,尽管这似乎是设计时元素),设计人员已经在时间轴上进行了调整和安排,以便我可以在运行时通过代码检查它们的波形。像这样的事情:
// Imaginary Code
sc = timeline.getSoundClipByName("SoundClip1");
sc.extract(waveform,sc.length/1000 * bitrate);
这可能吗?谢谢!
In Actionscript 3 / Flash 10, is it possible to programmatically reference a sound object that exists on the timeline? I've found lots of examples for referencing DisplayObjects via the following sytax:
var m:MovieClip = stage.getChildByName("SomeMovieClipClass");
var n:MovieClip = stage.getChildByIndex(1);
But this doesn't seem to include sound objects. Similarly, it seems straightforward to instantiate and play a sound that exists in the Library via Actionscript:
var s:SoundClip1 = new SoundClip1(); // exported in first frame via properties
s.play();
For my purposes, though, I'd like to reference sound clips (ideally in a specific layer, although that seems to be a design-time element) that designers have adjusted and arranged on the timeline, so that I can inspect their waveforms via code, at runtime. Something like this:
// Imaginary Code
sc = timeline.getSoundClipByName("SoundClip1");
sc.extract(waveform,sc.length/1000 * bitrate);
Is this possible? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
截至目前,无法访问时间线声音生成的 soundChannel。这是我希望看到实现的功能。
我打算尝试测试使用computeSpectrum 获取时间线声音波形的可行性,但我现在在导入mp3 时遇到问题。由于缺乏第一手的概念证明,我四处搜索并找到了这个帖子:
http:// /www.kirupa.com/forum/showthread.php?t=329632
指向此解决方案的链接
http://www.mail-archive.com/[电子邮件;受保护]/msg43157.html
但是,这当然不允许您消除不同时间线声音之间的歧义。我很确定你根本无法做到这一点。
我从未使用过 Sound.extract(),但是如果声音存在于 fla 库中,这向我表明您可以简单地给它们一个类名,并在运行时使用 extract() 来收集波形以供您自己使用,是的?然后,每当播放适当的时间线声音时,您都可以从声音对象中点击波形。也许时间线回调或事件就足够了?
As of this date, no it is not possible to access the soundChannel generated by a timeline sound. It's a feature I would love to see implemented.
I was going to try to test the feasibility of using computeSpectrum to get the waveform of a timeline sound but I'm having problems importing mp3s right now. In absence of firsthand proof of concept, I searched around and found this thread:
http://www.kirupa.com/forum/showthread.php?t=329632
Which links to this solution
http://www.mail-archive.com/[email protected]/msg43157.html
But of course this doesn't allow you to disambiguate between different timeline sounds. I'm pretty sure you won't be able to do that at all.
I have not ever used Sound.extract(), but if the sounds exist in the fla library this indicates to me that you can simply give them a Class name and at runtime use extract() to gather the waveform for your own purposes, yes? Then whenever the appropriate timeline sound plays, you can tap into the waveform from the Sound object. Perhaps a timeline callback or event would suffice for this?