MackeyK24 Posted November 17, 2016 Share Posted November 17, 2016 How would pause ALL playing sounds... I am trying to make a pause (start/stop) functionality especially for in-game menu... Since i control the render loop and is NON-Anoymous function so can easy stop using the function that was started with... Works great but i need to PAUSE the sound too... How??? Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted November 17, 2016 Share Posted November 17, 2016 I pause like this. There is also system wide resume & playrate in this class done the same way Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 18, 2016 Share Posted November 18, 2016 Holy crap, Jeff! A TimelineControl? This is a time-based event sequencer! A scheduler-class object! ALRIGHT! Are you a musician, JC? Done some midi? I don't know if you heard me ramble about Midi Machine Control... which are essentially sysex messages (system exclusive) that are embedded within a midi song. The song then becomes the event sequencer... and ideally, I can "watch-for" those sysex messages arriving into the JS environment. Then, I can do things to mesh... on downbeats of the song. The mesh can dance to the beat of the song, because I edited the midi, and I inserted these hidden sysex bytes... within the sequence (at each downbeat). Later, these sysex messages can trigger pre-fetched .wavs, mp4s, etc... to play at certain places in the midi sequence, as well. This is my kind of event sequencer. ahh, sorry, I got excited about your TimelineControl. It made my nipples erect. heh. Will you (later) have a special TimelineEventClass object/template... that get "hung" on the timeline? Sigh. Life is good. Jc... blazing trail for us... takin' care of business. (See me bending this topic out of shape? Pathetic, eh? nod) Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted November 18, 2016 Share Posted November 18, 2016 This is an after renderer based clock primarily for (animation & sound) queuing synchronization, and game pause / resume / speed. I also tossed in an MP4capture hook, that uses precise nn frame rates. Looks really weird when doing say 24 fps on a 60 fps system, but capture is the reason it is an after renderer & not a before. That is not currently implemented. You should not be thinking that events have anything to with frames though. Everything is milli second based. I think Google Pixel runs @90 fps (others will follow), so this can take advantage of that without doing anything. FPS is so 20th century / film industry thinking. The events are all based off MotionEvent class with convenience class Stall. The morphing subclass is VertexDeformation with convenience classes Deformation, MorphImmediate, & BasisReturn. Skeleton subclass is PoseEvent. Events can be aggregated into an EventSeries for both repeating of an event sequence, and combining events from multiple queues, e.g. a jumping jack skeleton pose and a Breast shape key group morph. For a QI.Mesh there is a queue for just MotionEvents, if not doing anything else. If there is a skeleton, then QI.Mesh will have a separate queue for PoseEvents. There is also a queue for each shape key group maybe (Face, Wink, left hand, right hand, breasts, muscles, etc). Separate queues allows for independence like walking & talking. Coordinate together using an event series as needed. Enough for now, release for mid-next week. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 21, 2016 Share Posted November 21, 2016 ahh, the same motionEvents mentioned in the POV doc. yuh yuh yuh... I'm starting to see the light (barely). This might apply to @luknei's question about parallel blending of two separate animations: http://www.html5gamedevs.com/topic/26295-parallel-animations-blending/ Anyway, now he is pinged, he can read these JCPalmer words. (thx again, Jeff. excellent little summary!) Sorry for dragging your thread off-topic, Mackey. "Breast shape morph"... I kind of like the sound of that! Quote Link to comment Share on other sites More sharing options...
davrous Posted November 21, 2016 Share Posted November 21, 2016 Hi, I can implement a global pause / play method on the audio engine itself if you'd like. Cheers, David Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted November 21, 2016 Author Share Posted November 21, 2016 i end up going with this in the BabylonJS Toolkit Scene Manager API: public pauseAudio(): void { if (this._audioPause == false) { this._audioPause = true; if (this._scene.mainSoundTrack.soundCollection != null && this._scene.mainSoundTrack.soundCollection.length > 0) { var tracks: BABYLON.Sound[] = this._scene.mainSoundTrack.soundCollection; for (var i = 0, len = tracks.length; i < len; i++) { var sound: BABYLON.Sound = tracks[i]; if (sound.isPlaying) { sound.pause(); } } } } } public resumeAudio(): void { if (this._audioPause == true) { this._audioPause = false; if (this._scene.mainSoundTrack.soundCollection != null && this._scene.mainSoundTrack.soundCollection.length > 0) { var tracks: BABYLON.Sound[] = this._scene.mainSoundTrack.soundCollection; for (var i = 0, len = tracks.length; i < len; i++) { var sound: BABYLON.Sound = tracks[i]; if (sound.isPaused) { sound.play(); } } } } } If you wanna less those lines with some kine audioEngine.pause() and audioEngine.unpause() that would be very kool Quote Link to comment Share on other sites More sharing options...
davrous Posted November 21, 2016 Share Posted November 21, 2016 I'll work on that. I'm thinking about audioEngine.pause / play() and you have also to think about other soundtracks and not everything could only be in the mainSoundTrack Quote Link to comment Share on other sites More sharing options...
davrous Posted November 21, 2016 Share Posted November 21, 2016 Well, it would be simpler to put this code at the scene level as the audio engine is static owned by the Babylon.js Engine. So I can't access all possible scenes to pause their current audio objects. Quote Link to comment Share on other sites More sharing options...
davrous Posted November 21, 2016 Share Posted November 21, 2016 Wow. I forgot about my own code. I've already coded this feature. At the scene level, the only thing you need to do is to play with the audioEnabled property like: yourScene.audioEnabled = false Will pause all audio from the main track and second tracks yourScene.audioEnabled = true will resume them. I was surprised to have missed this scenario. David webGLmmk, GameMonetize and JCPalmer 3 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted November 21, 2016 Share Posted November 21, 2016 This is much better. After more testing, managing this directly was proving to be a nightmare. Pausing was fine, but the state of playing or paused was lost. Playing everything is not always the right thing to do. Un-did some half finished crap code to try to adjust, threw in those to lines, and was almost back on schedule. Still to meet Weds deadline, going to have to cut something. Heads down. @Wingnut, should remember this is a Blender only extension. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted November 22, 2016 Author Share Posted November 22, 2016 Oh Yeah... Much Better public pauseAudio(): void { if (this._scene.audioEnabled == true) { this._scene.audioEnabled = false; } } public resumeAudio(): void { if (this._scene.audioEnabled == false) { this._scene.audioEnabled = true; } } webGLmmk 1 Quote Link to comment Share on other sites More sharing options...
Nabroski Posted November 22, 2016 Share Posted November 22, 2016 i pause like that http://www.babylonjs-playground.com/#14FG1S#2 webGLmmk 1 Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted November 23, 2016 Author Share Posted November 23, 2016 Didn't see a pause option in your playground Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted November 23, 2016 Author Share Posted November 23, 2016 I think the scene.audioEnabled will work just fine Quote Link to comment Share on other sites More sharing options...
Nabroski Posted November 23, 2016 Share Posted November 23, 2016 it was a youtube hack, but they always take the link down after a time. so the idea is passing an audio as a video texture, video mp4 is likely supported then have various audio formats ogg.mp3 wav on a server and the fire one after an other only to see if one of them will be accepted by the client. I think you are working on the Unity BabylonJs Conversation, this would be weird if i export and mp3 and it ends as mp4 or webm This is meant to be experimental, for me, maybe also for someone else who came along this post, so i leave it here. @boyofgreen: with video you also has to do less math to find a duration. fixed:http://www.babylonjs-playground.com/#14FG1S#2 Quote Link to comment Share on other sites More sharing options...
webGLmmk Posted April 16, 2017 Share Posted April 16, 2017 Older thread, but this is how I used the Sound class: Sound.play(), sound.pause(), sound.stop(). http://www.babylonjs-playground.com/#KZQGPA#1 Does what it needs to. Next step is to try to put the pause on the same button as the play..i think i've got that worked out...and design of course @MackeyK24 @davrous @Nabroski Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.