How to play background sound (music) in GW-Basic - audio

I am developing a game in GW-Basic.i want to add music to it but the problem is that i am unable to play in the background but when i add sound then first the sound is played then after that game execution is started and vICE vERSA .while i want that both things play at the same time..so any idea how to do it??

This is actually possible. Use the PLAY "MB" statement to enable "music background" mode. In this mode all PLAY notes and SOUNDs are queued and executed in the background while your program is running. You can queue up to 32 notes. Look up PLAY in this manual.

Related

Godot 3.4.4 How to stop audio in html export?

There was a problem with audio playing in the exported instance of the game. The sound is played using the AudioStreamPlayer node. I export the game to html5 and run it either on a local server or on any service that executes html code. If during the game you minimize the browser, change the tab, make the game window NOT active, then all game processes are suspended, that is: the movement of all objects does not occur, all timers are suspended. BUT the music continues to play. I tried to handle a focus Notification , an input handle with a cursor to turn off the music, but this is not an option, because if you minimize the browser via alt + tab while on the tab with the game, then the focus does not go away and the input is still waiting (while as I said earlier, all other processes related to movement and the timer are suspended).
How stop this audio stream in this case?
thanks

LabView playing more than one sound at the time

I'm using event structure and want to do some like Launchpad.
Numeric keyboard have for each number added a sound.
Problem is, that when I press number example one, the program is waiting when the music stop play and next I can press example number four.
Is it possible, to play sounds from 3 key's at the same time using event structure ?
I put the files online here and added screenshots below. Block diagram:
Front panel:
Working Solution
I think I got this working much more easily than I expected using the Play Sound File VI under the Graphics and Sound -> Sound -> Output palette. That link is the 2011 documentation (couldn't find a more recent link), but it does not look like it has changed. The working result is shown below, with two different events handled by the event structure:
Key Down? event:
Stop Button event:
You may be fine without using the Sound Output Clear VI to the right of the main event loop, but having it there won't hurt.
It turns out that the Play Sound File VI does not block, so you can play multiple overlapping sound files. If you run into blocking on your machine (one sound file plays, then the next, and so on), let me know because I have another solution that might work.
A word on events
An important thing to understand is that events are handled in a queue. When you press keys, those key presses go in order onto the event queue. Each time your event-handling loop executes, it takes the oldest event out of that queue and processes it. The event structure in LabVIEW will only handle one event per iteration of your event-handling loop. On the next iteration, if events are still in the queue that your structure is set up to process, it will take the next-oldest one for that iteration and repeat.
Now, lets say that you want to do some super complicated processing that takes 10 seconds every time you press a key, and you put that processing inside of your main event loop. Your key presses still go onto the event queue as fast as you press them, but LabVIEW has to wait the full 10 seconds before it can dequeue the next keypress and process it, so you end up with an application that seems to hang while it chugs through the queue much slower than you are adding items to the queue.
One way to get around this is to take that complicated processing and put it outside of the queue in another process. If you have the resources, you can actually call a separate instance of a processing sub-VI in its own thread for every one of those key presses. This allows the event handling loop to spawn processes as fast as you can press keys, and then your processes take whatever time they need to simultaneously (resources permitting) perform whatever actions you wanted.
Essentially that is what the Play Sound File VI is doing. It sees that you want to play a file and spawns a process to play that sound over the speakers, allowing the event-handling loop to continue immediately rather than waiting for the sound to finish playing. As you press more keys, more processes get spawn that kill themselves when they are finished. You can do this manually too, which is the other solution that I have for you if Play Sound File does not behave the same way for you as it did for me.
Update:
Thanks to #Engineero for pointing out that Play Sound File vi actually isn't blocking. The updated code shows how to play overlapping sounds. I'll leave it to the user to add the Stop Sound on Key Up code. No timeout is needed because nothing is taking place in the event structure.
Also, note that for me the Play Sound vi needed to be in a while loop to keep playing. Not sure why this is needed, but the NI examples sets it up this way (\examples\Graphics and Sound\Sound\Sound Player.vi).
Finally, you may crash the vi if your sound card gets overwhelmed as mentioned here. If that happens I would go with a better sound library to try and squeeze more performance out of your sound card.
Original:
First, I assume you a referring to this Launchpad?
I was able to press up to 4 keys at once will the following - the important thing is to set the event timeout to 1 ms. If you need more than that it will require a more sophisticated design.
I was no able to easily implement a sound because all the basic LabVIEW beeps are what's considered "blocking I/O" meaning if you call 2 Beeps simultaneously than Windows will play one after another not both at the same time. You will need to implement you instrument notes using non blocking I/O probably in a language other than LabVIEW such as this C++ library.

Music replay does not work on Libgdx

I have a sound track for my game, which I play when player enters a level, and stop when the level ended.
Sound track is a Music class with looping set to true, and loaded through an AssetManager.
It works fine for the first level, I can hear the music, and when the level ends, I call stop. On the start of the second level, I cal start again, but I cannot hear any music. There is no error or exception either.
From the documentation, I thought I can user the same Music class instance, so theoretically it should work AFAIK.
Any idea why it doesn't work?

How long i will run a timer in background?

In my application i am running a timer in background for every 8 seconds to play a custom sound,it works fine ,but it get stops at later sometime,so how can i play the sound continuously in background?
Currently i am using the below code to play the sound in background
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID);
AudioServicesPlaySystemSound(soundID);
let me know the good solution to play the sound continuously in background
Short answer: your app is simply suspended.
Long answer: You are missing key parts of the background savvy implementation.
You need to tell the iOS that you are an Audio App, and that you are requesting extra cycles when suspended.
The UIBackgroundModes is subject to approval
From the documentation:
Background modes for apps:
UIBackgroundModes value = audio
The app plays audible content to the user or records audio while in the background. (This content includes streaming audio or video content using AirPlay.)
If your app does not fall into any of the categories below, then your only option to extend backgrounding beyond the typical 5 seconds is to invoke -beginBackgroundTaskWithName:expirationHandler:. You will likely be suspend within 30 seconds or so.
audio
location
voip
newsstand-content
external-accessory
bluetooth-central & bluetooth-peripheral
fetch
remote-notification

montouch detect when sound finished playing

In objective C is a method called AudioServicesAddSystemSoundCompletion which allows to add a handler for "audio done notification".
So I add the handler call AudioServicesPlaySystemSound and when the sound finished I'll get a notification.
monotouch has MonoTouch.AudioToolbox.SystemSound.PlaySystemSound to play such a sound.
But how do I know when the playing finished?
Situiation: I have a class which get's some information. When this information indicates an error I play a sound. If I'm already palying a sound I should do nothing.
And depending on a setting ("repeat alert") I should play the sound again the replay finished and the alert is still valid.
Sounds not so complicated - but without knowing when the sound finished playing I have a problem. So I can neither detect that I already play - nor can I repeat if needed.
This isn't bound in MonoTouch yet, you should file an enhancement request at http://monotouch.net/Support so we can expose it properly.

Resources