GLBasic forum

Codesnippets => Code Snippets => Topic started by: Hemlos on 2008-Oct-29

Title: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: Hemlos on 2008-Oct-29
Play any multimedia, once. Including, midi.
Control any supported multimedia device, including waveform-audio devices, MIDI sequencers, CD audio devices, and digital-video (video playback) devices.
WIN32 only i think.

PAUSE RESUME STOP VOLUME:
NOTE: For compressed files like .avi:
These additional commands, Only work with the MCI_PLAY() command.
These wont work with MCI_PLAYMOVIE(), this one is standalone, see sample in zip file.

Midi/Sound Notes:
MCI_PLAY(filename$,FALSE) // The BOOL(true/false) expression is for movies only, fullscreen option
Midi can only use play and stop.


FOR MORE INFO CHECK THE UPDATE LOG, IT IS POSTED IN MY BLOG!

-Hemlos
PS. if you want more support for this library, let me know, ill add/change/edit.

HERE IS THE SAMPLE AND LIBRARY ZIPPED BELOW, MCI_LIBRARY.ZIP:

[attachment deleted by admin]
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: momosxp on 2009-Jul-13
seems to be win32 only..

when i try to compile it for wiz:

Code: (glbasic) [Select]
compile+link:
/cygdrive/c/Users/Mohammed/AppData/Local/Temp/cckY43XR.o: In function `__GLBASIC__::MCI_VOLUME(__GLBASIC__::DGStr, float)':
gpc_temp0.cpp:(.text+0x1d8): undefined reference to `mciSendStringA'
/cygdrive/c/Users/Mohammed/AppData/Local/Temp/cckY43XR.o: In function `__GLBASIC__::MCI_PLAY(__GLBASIC__::DGStr, float)':
gpc_temp0.cpp:(.text+0x330): undefined reference to `mciSendStringA'
/cygdrive/c/Users/Mohammed/AppData/Local/Temp/cckY43XR.o: In function `__GLBASIC__::MCI_PLAYMOVIE(__GLBASIC__::DGStr, float, float)':
gpc_temp0.cpp:(.text+0x500): undefined reference to `mciSendStringA'
/cygdrive/c/Users/Mohammed/AppData/Local/Temp/cckY43XR.o: In function `__GLBASIC__::MCI_STOP(__GLBASIC__::DGStr)':
gpc_temp0.cpp:(.text+0x8b8): undefined reference to `mciSendStringA'
/cygdrive/c/Users/Mohammed/AppData/Local/Temp/cckY43XR.o: In function `__GLBASIC__::MCI_PAUSE(__GLBASIC__::DGStr)':
gpc_temp0.cpp:(.text+0x9d8): undefined reference to `mciSendStringA'
/cygdrive/c/Users/Mohammed/AppData/Local/Temp/cckY43XR.o:gpc_temp0.cpp:(.text+0xaf8): more undefined references to `mciSendStringA' follow
*** FATAL ERROR - Bitte die Compiler-Ausgabe ins Forum kopieren
_______________________________________
*** Fertig ***
Dauer: 2.7 sek. Zeit: 18:53
Erstellen: 0 erfolgreich.
*** 1 FEHLGESCHLAGEN ***
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: Kitty Hello on 2009-Jul-14
MCI is windows, only. Try PLAYMUIC for Wiz.
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: momosxp on 2009-Jul-14
easy to say, hard to do :D
http://www.glbasic.com/forum/index.php?topic=3071.15
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: Kitty Hello on 2009-Jul-14
play with the sample rate. The Wiz can play ogg and mp3.
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: momosxp on 2009-Jul-14
yes ogg and mp3 work on wiz but ogg crashes the wiz after 3 played ogg (not played on same time) files and mp3 stutters
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: Hemlos on 2009-Jul-14
yes ogg and mp3 work on wiz but ogg crashes the wiz after 3 played ogg (not played on same time) files and mp3 stutters

That sounds like memory issues.
1. Try setting your sample rate, lower....to use less compression. This will reduce the size of the file.
2. Are you using buffers # in the project options? if you are, try using 0.
3. Are you reusing the original memory slot and loading the new song in the old memory position?

Sound/Music is an age old problem, Escpecially with machines getting smaller, and music files getting bigger.
This is why midi was introduced ages ago, and now, for obvious reasons, it is actually desireable.
Unfortunetly you dont have access to these solutions with a WIZ, so you will need to dive into the problem at the rawest levels...sound compression, memory/buffer allocation, and reusing the memory.
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: MrTAToad on 2009-Jul-15
Does FMOD work on the WIZ ?
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: Kitty Hello on 2009-Jul-16
no. On the wiz I use SDL_mixer for sound. It really should work.
I can try changing some of the buffer parameters if there's really that much problems. But Ian had music in his game and it played nicely.
His settings were:
ogg/vorb, stereo, 22050Hz, Bit rate 88kb/s.
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: momosxp on 2009-Jul-16
i don't think it's a memory problem. The whole game (including exe + gpe file) has 6,5mb.
But how to use Buffers? And how to reuse the memory with playmusic?
Now i just use it like this

Code: (glbasic) [Select]
newmusic:
if blabla 1
 stopmusic
 playmusic ""
 playmusic "bla1.mp3"
elseif blabla 2
 stopmusic
 playmusic ""
 playmusic "bla1.mp3"
endif
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: Hemlos on 2009-Jul-16
Does that work momo? Or is it still problems?

Post your song as an attachment here.
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: momosxp on 2009-Jul-16
mp3 still stutters.. tried even with 16bit rate (doen't even play) and 32bit stutters a bit.. but still stutters and in some levels there are problems with the whole game performance because of that.

Tried ogg again with low quality and it works now. The 4 Soundfiles for Backgroundmusic are as big as the half size of the game but it works. That counts now.

Thanx for help :)

But i think that's a basic problem of GLBasic. Sound is a very important thing for Game Development.
And GLBasic adverts with Multiplatform compatibility. So it should have full compatibility for mp3 or at least for midi on WIZ/GP2X.
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: Kitty Hello on 2009-Jul-16
Well, what should I do? Others have the same limitation. I'm just using the SDL library.
I'll see if others initialize with a bigger/smaller buffer, though. But I really remember that I tweaked these values for a whole day, since playing WAV did stutter otherwise. The sound output of the Wiz is, well, sub-optimal.
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: momosxp on 2009-Jul-16
Ohh i know that it's not that easy fixing that. But i only wanted to say that it should be fixed as fast as possible :)

But now i have to say sorry because ogg is really working well now. The filesize is bigger than mp3 or midi. But because of the crashs.. it only crash on my computer. I don't know why. On WIZ it's working well. I think i have some codec problems on winvista with ogg. But now i split it up in two projects.
One with mp3 for pc and one with ogg for wiz/gp2x.
What's about sound on GP2X. I don't own one. I think i have to look for some betatesters before uploading the gp2x version to filearchiv :)
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: Ian Price on 2009-Jul-16
I have .ogg codec problems on my laptop under XP - I can't hear a thing. Works fine on my main pc and Wiz though.
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: Hemlos on 2009-Jul-16
Quote
GP2x audio specs:
2 Channel Stereo(L+R)
Frequency Response 20Hz~20KHz
Sampling Rate 16bit/8~48KHz
Supported Formats MP3, OGG

GP32 audio specs:
2 Channel Stereo(L+R)
44.1 KHz 16-bit stereo sound


16 bit is the specs, but you have to make sure the frequency is 8~48khz

I would start with the gp32 specs for compatibility:

mp3, 44.1khz 16bit
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: gp2xboyuk on 2019-May-29
It says this attachment was deleted by Admin, is there any reason? I could do with better control of audio than normal basic commands and this library looked perfect.
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: SnooPI on 2019-May-29
Hi gp2xboyuk,

Why do you need this (old) library?
The standard audio functions of GLBasic are now sufficient (only 3D is missing).
You can play wav, ogg, midi, mp3, ... and of course, multiplatform, not like this library.
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: gp2xboyuk on 2019-May-29
Standard GLBasic functions don't let you write apps, as there is no pause/play, or jumping to a certain point in mp3 so can't code an MP3 player or audiobook player etc etc
Also even for games it's nice to be able to have more advanced code to have music fading or changing depeding on zones or what is happening, all in one file and being able to jump to certain points, fade betwen parts etc so no fps drop whilst loading another mp3.
Mainly though as I say, I want to code an MP3 player :D
Tis library really looks to be essential for those not just wanting a gaming language, I always think of GLBasic as being ideal for coding applications.
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: SnooPI on 2019-May-31
Ah ok, I understand.
The best thing to do would be to create a wrapper for a library of sounds like http://www.portaudio.com/ (http://www.portaudio.com/), because it's a cross-platform library.
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: Hemlos on 2019-Jun-01
Quote
The best thing to do would be to create a wrapper for a library of sounds like http://www.portaudio.com/, because it's a cross-platform library.

Strange, i didn't delete it. :blink:

Snoopy is correct, MCI is win32 only, and is not compatible with anything except windows.


Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: Hemlos on 2019-Jun-01
BTW 3d sound is not "missing", it is something you need to implement with orientations and positions in 3d.
This might be a snippet i work on in the future.

In theory, this algorithm will consist of inputs for; a receiving position, a source position, and a pointto orientation, and general volume.

The output will be a "balance" and "loudness", which is derived from left/right/forward/backward/distance relative 3d positions.
Title: Re: MCI library, (WIN32), All multimedia, Play, Pause, Resume, Stop, Volume
Post by: SnooPI on 2019-Jun-01
If we have to program them, it means they are missing.
I know something about it because I programmed it for one of my 3D games (and it was not so easy). In addition, it must be fast and multi-platform.
My routine was not 100% complete but was sufficient at the time.

Good Luck Hemlos !  =D ;)