GithubHelp home page GithubHelp logo

Comments (7)

Venjier avatar Venjier commented on May 23, 2024

我们公司的业务里也有这个需求,我的做法也是类似的,高 bpm 的时候节奏不均匀是因为,音频是有时长的,而不是一瞬间,上一个音频还没有播放完毕就开始播放下一个,就会导致这种节奏不均匀的问题,我的做法是,用两个播放器轮流播放,而不是一个播放器循环到底,加上另外一个音源,一共是三个播放器,其中两个交替播放,另外一个是每四拍子播一次,这样 bpm 的上限就翻了一倍了

from metronomelutter.

zhanwj-zz avatar zhanwj-zz commented on May 23, 2024

我们公司的业务里也有这个需求,我的也是类似的,高 bpm 的时间节奏不一样是因为,音频是有时长的,而不是一瞬间,上一个音频还没有完成就开始播放下一个播放,启动这种节奏不均匀的我是,用播放器轮流播放一个问题,而不是一个播放器,添加另外一个循环源,另外一个循环播放器,包括两个循环播放器,其中两个播放器是最终播放器,另外每四拍子播,这样 bpm 的播放量就翻倍了
大佬可以分享一下方案吗,我想借鉴一下,因为我还加了除4分之一拍的很多节奏型

from metronomelutter.

Venjier avatar Venjier commented on May 23, 2024

公司的代码,不方便上传,我给你讲讲我的思路:我是用定时器实现的,创建定时器之前先把音频缓存好,AudioPlayer 的文件路径先设置好,这里直接 new 三个 AudioPlayer,其中两个是 soundType1,也就是节拍器里面普通的那个声音,另外一个是 soundType2,也就是每隔几拍会播放一次的特殊的那一声,三个都设置好了之后再创建定时器,定时器外搞一个 int 变量,定时器运行一次就加一次,然后定时器里面用这个变量 % 2,为0播放第一个,为1播放第二个,这样高 bpm 的问题就解决了,节奏型的话也是用这个变量求余,大概思路就这样

from metronomelutter.

zhanwj-zz avatar zhanwj-zz commented on May 23, 2024

公司的代码设置方便上传,给你的想法是我用我的思路来表达我的想法,是我的三个音频播放器之前讲的好声音,先把音频播放好,直接播放好,直接播放,其中,也是那里面的声音类型1,也是另外一个声音类型2,也是普通的几拍之后的会播放一次,分别是那个好设置一次声音类型,分别是那种声音类型外边的变量就为运行一个问题,就运行一次,然后打个电话2个,为0这样播放,第二个,高高的这个变量解决了,节奏型也用这个变量求余,大概思路就这样

感谢老哥回复,谢谢

from metronomelutter.

Venjier avatar Venjier commented on May 23, 2024

AudioPlayer 里面有个方法可以让音频跳转到指定的位置,每次播放前你都让音频跳转到 0 毫秒的位置,可能也能解决你的一些问题

from metronomelutter.

Tyrone2333 avatar Tyrone2333 commented on May 23, 2024

@Venjier @zhanwj-zz 我就是因为解决不了这个问题,把 app 都从酷安下架了! 如果你们解决了请给我提个 pr😭

from metronomelutter.

Tyrone2333 avatar Tyrone2333 commented on May 23, 2024

我有怀疑过是定时器间隔不精确的问题, 里面有个分支是尝试用类似游戏引擎的无限循环方式, 在循环里面算时间戳间隔,但是也无法精确到1ms

from metronomelutter.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.