Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I would like to write a program that "arranges" multiple audio buffers. Similar to a DAW, I want to "layer" audio tracks on top of each other at custom timestamps. Is this even possible, and if so, how would I implement it?
I apologize in advance for this extremely general question, but I couldn't find any good resources on this topic. Thanks for the help!
Yes, this is possible.
First, load your audio data into AudioBuffer instances.
Next, you want to create an AudioContext, which is basically the root of a graph of connected nodes where your audio flows about.
Now, create an AudioBufferSourceNode for each AudioBuffer and connect it to the audio context's destinationNode. This basically plugs a buffer player directly to the output.
From there, you can call .start() on your AudioBufferSourceNode instances to play them back immediately, or schedule them to play at some point in the future.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I did a background music which is hidden and only one music by mp3, it can autoplay and repeat when open the website.
I want to make a playlist, I tried many ways and found many ways, but it cannot be worked, how can I do if I put 3 or more than 3 musics into the website, the musics are in my computer.
There are plenty of great libraries that will be just right for you. My favourite one is howler.js - very easy calls and does pretty much anything you'd like to do with audio files.
Howler.js: https://howlerjs.com/
Sound.js: https://www.createjs.com/soundjs
Waud.js: http://www.waudjs.com/
Wavesurfer.js: https://wavesurfer-js.org/
and many more audio.js out there :)
If you don't know how to create HTML markup of music player for your JS methods, above libraries provide great examples, so you can easily copy the stuff you need. Hope it helps!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
If you're not familiar with the concept of a Microgame, check out this video of WarioWare Twisted.
I'm interested in setting up a site where users can play series of browser-based Microgames which are delivered to them by a server. Ideally this would allow me to crowdsource the games and have an open submission system. What sort of scheme could I use to make this work?
I'm thinking that one way to do it would be to have each game consist of:
A javascript file that defines a MicroGame object that controls a rectangular portion of the screen, gets input and timing information from the main page, then calls back to the main page with a "Success" or "Failure" message.
A folder of assets that must be downloaded before the game executes.
Is this possible to do, client-side within a browser? Where would be a good place to start figuring this out?
There are a lot of open issues here. The biggest problem is what language do they submit games in which you can execute safely on the players machines? That said, there are tools like this out there. You could look at the excellent Play My Code for inspiration.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am trying to create a service that allows real-time concurrent modification of canvases by more than 2 users. I have been exploring the literature behind the best ways of doing this and have not found a lot to go of off.
So far I have found methods which serialize the canvas using the canvas.toDataUrl(). The issue here is that it seems rather inefficient to redraw the entire canvas when only very few pixels have changed (that is, when another user modifies it).
I do not really know where to start with this particular project and would love some help with that.
No more than 40 users would be looking at the canvas at once.
Depends on what and how users are drawing.
If they can draw/manipulate only predefined set of primitives, like software block chart then you can send just list of JSON serialized data describing those primitives and their location.
If drawing is just a pixel bitmap like this http://intridea.github.io/sketch.js/ then you can do drawing into bitmap and broadcasting that bitmap serialized as PNG on mouseup or so.
To publish this to all users I would do something socket.io based. Node.js for example has a lot of samples of how to do socket.io based chats. Chat is conceptually pretty close to what you want to achieve.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
So I am on the 11th level of my game (plan to have 20-25) and listening to the music that is going to be on the game, over and over, to see if it fits while testing it.
Now I've decided it is time to start working on the media player for it.
I plan to have all the songs on a loop. You can skip songs or go previous and play/pause. There also will be a button to mute.
I know how to add the GUI to the screen and use the mouse clicks to trigger methods. Just wondering what is the most used way instead of building it from nothing and wasting time.
I am just wondering if there a tut/guide as I plan on pulling an all-nighter to do this.
I'm in college but it's summer so decided this would be great for my portfolio.
Here's a demo vid of it. It is my first game so go easy! :)
Use the <audio> tag. It has functions such as .play() and .pause(). To switch tracks, you'd modify the src to point to a different audio file, much in the same way you'd switch the src of an <img> tag to display a different image.
EDIT: I just watched video and I want to play this thing. The twist on the normal platformer (all the platforms being ones that you slowly fall through) could either be really awesome or really frustrating. I'm leaning towards awesome but that remains to be seen!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am creating a craps game using javascript. I have pretty much everything working the way its supposed to be, just have to make a few minor adjustments, but the part I am stuck on is creating some type of type function, or possibly using the setTimeout(). I have a .wav file playing the sound of dice being rolled, but what I would like to do is have the text if the user won or lost appear after the sound of the dice being rolled(after the .wav file stops playing the dice rolling sound).
I don't think you can detect any event about the sound file ending.
You should play the sound, then start a setTimeout function with a hard-coded duration.
Eg:
setTimeout(diceRolled,3000); //these are millisecond -> 3 seconds wait
// ..........
function diceRolled(){
//do anything here
}
I would say the "correct" answer is to use html5 audio and bind to its various events - you can get the file's duration, detect if a sound has finished playing, get its current playback location, etc.
However, it's fairly complicated to use, and I wouldn't recommend it for this purpose or for starting javascripters.
http://html5doctor.com/html5-audio-the-state-of-play/
http://www.html5rocks.com/en/tutorials/webaudio/intro/