Playing audio file with golang - go

How one would play audio file in go language?
I have function and want sound to be played as notification when event happens.
I could not find anything about playing sound file in go lang just some web browser based music players but it wasnt helpful too much.

You could use the PortAudio Go bindings (go get github.com/gordonklaus/portaudio) for this.
You will have to build or install PortAudio on your system. Consult http://portaudio.com/docs/v19-doxydocs/tutorial_start.html for this.
A complete example for playing back a sound file is located at https://github.com/gordonklaus/portaudio/blob/master/examples/play.go

If it's an MP3 file, you can use go-mp3 Library. go-mp3 is popular library to play MP3; MP3 decoder is in pure Go.
Or this one, https://github.com/faiface/beep. Beep uses go-mp3 under the hood

Related

How do I play an MP3 file using Lazarus on macOS

I'd like to be able to play an MP3 file programmatically, using Lazarus on macOS.
Lazarus 2.0 (fpc 3.0.4) on macOS is working great for me, but one thing I cannot manage to do is to play an MP3 file programmatically.
I managed to compile and run the OALSoundManager demo project, but only WAV files can be played that way.
I spent several hours following various leads from the freepascal forum, but I still could not manage to do the basic play operations:
Load an MP3 file
Start playing it.
Get the current playing position (e.g. during OnTimer).
Be notified when it stops.
I'm OK with using any common library. Of course the less dependencies the better.
Once I can play the file I can figure out the rest, but it would be great if the example also showed:
Start playing from a given time position
Pause/Restart
Thank you very much for any help!
You might be able to use Castle Engine and OpenAL.
You can install Castle Engine from with-in Lazarus. In the main menu under "Package" -> "Online Package Manager" you will be able to filter and install "castle".
Then you should be able to open the example project:
https://github.com/castle-engine/castle-engine/blob/master/examples/audio/alplay.lpr
Goodluck,

Playing video in Qt (on a Mac)

This question arises out of a combination of this being my first time working with video and unfamiliarity with Macs. Basically I'm finding it difficult to figure out how to play a video (within a QWidget, or otherwise) using any standard format, e.g. avi, mpeg, mov, etc. In particular,
QMovie::supportedFormats() gives me only .gif and .mng, but I need to use standard formats. Is there a way to increase the number of supported formats?
Phonon requires the presence of a 'backend' which the user has to implement himself. I looked to see if I could somehow do this with Quicktime, but I couldn't get the application to launch--and anyway I didn't really see how to do that. Also, Phonon looks pretty heavyweight, I'd like to avoid it if I could.
While there are plenty of avi (et al.) players floating around on the web, I think it's probably unlikely I'd be able to use them--I need to start, stop, and change the playback speed of videos programmatically i.e. through my C++ program.
I'm not sure why this should be so hard--working with images in Qt is a snap by comparison. So: What's a good way to play videos from within a C++/Qt program?
Stop what you are doing right now: Phonon is the past, Qt Mobility is the future.
After you download, compile and install Qt Mobility, check the examples: videowidget and videographicsitem, located at: qt-mobility-opensource-src-1.2.0/examples/
They pretty much answer all your questions.

How can I play the system's special sound? For example the drag-n-drop sound

On the Mac, when a drag-n-drop has finished,a special sound will be played. How can I play the same sound programmatically?
I don't know if you can use a system call to tell the system to play that sound, but I think that an easy solution is to find the sound file on your system and use it in you program. ;)
Just use something like Audio Hijack Pro to record the system audio while you perform a copy operation. Then you can use the resulting audio file.
I can't say this is legal, seeing that you'd be using copyrighted resources.

Are there libraries to develop a audio streaming client on the mac or iPhone?

Before reinventing the wheel, I'd better check out if there are solutions I can buy or get for free?
I want to make a little web radio streaming app for my sister. Maybe there's a library that can play streams from the web?
VLC is an open source player that can also be uses as a streamer
see also :
Which frameworks / libraries should I take a look at when I want to play an audio livestream on the iPhone?
You may want to check out wowza

programmatically recording sound sent to Built-in Output, Mac OS X

I have a conundrum:
I need to find a way to capture the raw audio data that is being piped to the Built-in Output on Mac OS X. Core Audio, HAL, etc.
I can "listen" in on the Built-in Output and the mic, but neither of these appear to offer the correct data stream - the exact stream (all combined data from all input sources) that goes to the speakers/built-in output.
Any advice is welcomed with appreciation.
maybe you should have a look at the Jack source code...
http://sourceforge.net/projects/jackosx
Do you need to access to that stream from your program, or do you just want to rip audio from it? In the second case, a quick Google search turned up http://www.ambrosiasw.com/utilities/wiretap/ and http://www.rogueamoeba.com/audiohijackpro/. None of those are open-source or free though.
Edit -- whoops, you want to access to programmatically, that answers my own question, sorry. I think I'll keep my answer here in case some folks stumbles upon this page wanting to record audio non-programmatically.
You need will need your app to install a system extension.
Soundflower is an open-source implementation of such an extension.

Resources