Jump to content

[SOLVED] - Pause the audio engine


MackeyK24
 Share

Recommended Posts

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???

 

 

Link to comment
Share on other sites

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.  :D

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!  :D

 

Link to comment
Share on other sites

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 :)

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 months later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...