IrrKlang Wrapper for FreeBasic

User contributed sources that have become inactive, deprecated, or generally unusable. But ... we don't really want to throw them away either.
Post Reply
Frank Dodd
Posts: 444
Joined: Mar 10, 2006 19:22

IrrKlang Wrapper for FreeBasic

Post by Frank Dodd »

Image

I have recently released the IrrKlangWrapper v0.1 (link), it supports 21 commands, contains 4 examples and provides a basic but well featured interface to the audio library: -
  • Load and manage sounds and music
  • Playback of 2D audio files
  • Playback of 3D audio files
  • Controls for volume, pause, position control and playback speed
Example of use: -

Code: Select all

' start the irrklang sound engine
IrrKlangStart

' Play a sound
IrrKlangPlay2D ( "./media/HelloWorld.wav" )

' sleep while the sound plays
print "Press a key to end"
sleep

' Stop the IrrKlang sound engine and release resources
IrrKlangStop
While the wrapper is released under an open license, IrrKlang is a commercial library that is only free for non commercial use, please refer to the IrrKlang library license separately for details.

My thanks to everyone that helped with this and I hope its found to be useful.
Last edited by Frank Dodd on Sep 11, 2010 8:12, edited 3 times in total.
afecelis
Posts: 85
Joined: Feb 20, 2009 22:34
Location: Colombia

Post by afecelis »

Fantastic! Thanks a lot Frank, downloading and testing right away ;)

regards,

Alvaro.

ps. The only issue is that Irrklang definitely doesn't work on 64bits Linux, as stated by Niko himself. Let's see if a similar trick to the one used for the IrrlichtWrapper can get it to work. ;)
afecelis
Posts: 85
Joined: Feb 20, 2009 22:34
Location: Colombia

Post by afecelis »

OK, here we go, compile-error report time:

Code: Select all

crunchbang@crunchbang:~/exer/IrrKlangWrapper/IrrKlangWrapper_source$ make
g++ -I../../irrklang-1.1.3/include -MM -MF wrappersound.d wrappersound.cpp
g++ -I../../irrklang-1.1.3/include -MM -MF wrappersystem.d wrappersystem.cpp
g++ -I../../irrklang-1.1.3/include -MM -MF irrklangwrapper.d irrklangwrapper.cpp
g++ -Wall -fexpensive-optimizations -O3 -I../../irrklang-1.1.3/include -I/usr/X11R6/include  -c -o irrklangwrapper.o irrklangwrapper.cpp
In file included from irrklangwrapper.cpp:15:
irrklangwrapper.h:23:22: error: irrKlang.h: No such file or directory
In file included from irrklangwrapper.cpp:15:
irrklangwrapper.h:29: error: ‘irrklang’ is not a namespace-name
irrklangwrapper.h:29: error: expected namespace-name before ‘;’ token
irrklangwrapper.cpp:21: error: expected constructor, destructor, or type conversion before ‘*’ token
make: *** [irrklangwrapper.o] Error 1
crunchbang@crunchbang:~/exer/IrrKlangWrapper/IrrKlangWrapper_source$
I'm checking the file now to see how the path to irrKlang.h is stated ;)
Frank Dodd
Posts: 444
Joined: Mar 10, 2006 19:22

Post by Frank Dodd »

Thanks very much for the post Alvaro, I haven't built the IrrKlangWrapper under Linux yet, I will do that on Monday when I have access to my Linux box again and if successful I will probably just include the binaries into the linux build. My Linux box is quite basic though so I am not sure what multimedia support it has, I will give it a go though.

As long as the irrklang.1.1.3 directory is at the same level as the IrrKlangWrapper folder you should be good to go. However the makefile probably needs some switch embedded to build for 32bit rather than 64bit.

If you try changing: -
CXXFLAGS = -Wall
to
CXXFLAGS = -Wall -m32

That might help it build for 32bits, its looks like its almost there.
afecelis
Posts: 85
Joined: Feb 20, 2009 22:34
Location: Colombia

Post by afecelis »

Great! Linux support would be awesome again. ;) It will simplify adding sound to our IrrWrapper applications, a killer combo! :D

I just tried your new flag for the makefile and got this:

Code: Select all

crunchbang@crunchbang:~/exer/IrrKlangWrapper/IrrKlangWrapper_source$ make clean
rm -f irrklangwrapper.o wrappersystem.o wrappersound.o libIrrKlangWrapper.so.0.1 libIrrKlangWrapper.a irrklangwrapper.d wrappersystem.d wrappersound.d
crunchbang@crunchbang:~/exer/IrrKlangWrapper/IrrKlangWrapper_source$ make
g++ -I../../irrklang-1.1.3/include -MM -MF wrappersound.d wrappersound.cpp
g++ -I../../irrklang-1.1.3/include -MM -MF wrappersystem.d wrappersystem.cpp
g++ -I../../irrklang-1.1.3/include -MM -MF irrklangwrapper.d irrklangwrapper.cpp
g++ -Wall -m32 -fexpensive-optimizations -O3 -I../../irrklang-1.1.3/include -I/usr/X11R6/include  -c -o irrklangwrapper.o irrklangwrapper.cpp
In file included from irrklangwrapper.cpp:15:
irrklangwrapper.h:23:22: error: irrKlang.h: No such file or directory
In file included from irrklangwrapper.cpp:15:
irrklangwrapper.h:29: error: ‘irrklang’ is not a namespace-name
irrklangwrapper.h:29: error: expected namespace-name before ‘;’ token
irrklangwrapper.cpp:21: error: expected constructor, destructor, or type conversion before ‘*’ token
make: *** [irrklangwrapper.o] Error 1
crunchbang@crunchbang:~/exer/IrrKlangWrapper/IrrKlangWrapper_source$
About your Linux box, if you have a 1gb or bigger USB pendrive you could give crunchbang a try, this way you can plug it into your windows machine and boot form the usb and take advantage of the hardware your plugging your drive into. Here's the tut on how to install it form windows using the iso, extracting some files and making the usb drive bootable:
http://www.pendrivelinux.com/crunchbang ... l-windows/

It's what I'm doing now in order to have a 32bit build environment without the cost of doing a full hard drive installation. ;)

regards,

Alvaro
Frank Dodd
Posts: 444
Joined: Mar 10, 2006 19:22

Post by Frank Dodd »

Do you have IrrKlang installed to the same parent folder as the IrrKlangWrapper folder?
afecelis
Posts: 85
Joined: Feb 20, 2009 22:34
Location: Colombia

Post by afecelis »

Yup, I got the "irrKlang-1.1.3" folder at the same level as the irrklangwrapper folder. ;)
Right now I'm trying it out in windows and it's great!

Can I just include the irrklang .bi file in my irrlicht application and add sound to it? (i.e. background music). Iguess the best way is to test it out ;)

regards,

Alvaro
afecelis
Posts: 85
Joined: Feb 20, 2009 22:34
Location: Colombia

Post by afecelis »

wow! I just tried and indeed adding a background music to my level was a just a matter of adding a couple of lines. Works great! :) Nice and simple.

I'll try some of the play3d functions. This reminds me of a question I already asked you before; If creating 3d sound nodes in irredit, will they be recognized by Irrklangwrapper+Irrlichtwrapper?

And one last thing, I tried loading an mp3 file and got an error saying I didn't have the mp3 dll file to be able to read them. The included dll is only for .wav sounds?


regards,
Alvaro
Frank Dodd
Posts: 444
Joined: Mar 10, 2006 19:22

Post by Frank Dodd »

Excellent news Alvaro. I think this does make adding sound very simple indeed, it should be easy also to know when keys are pressed to play footstep wav's etc.

The IrrEdit sound nodes will not work at the moment I might try and come up with an alternative solution for this.

I wrote a bit about the MP3 issue in the introduction document that should explain the situation with that, but yes if you copy the ikpMP3.dll from IrrKlang to IrrKlangWrapper you should have full MP3 support. I think I am personally going to stick with the ogg format myself though.

Thanks for your support,

Frank
afecelis
Posts: 85
Joined: Feb 20, 2009 22:34
Location: Colombia

Post by afecelis »

Thanks a lot Frank and excuse me for not reading the docs, but you know I always try first and read later, hehehehe ;) It's great to know that the Irrklang.dll supports ogg. I'm also a deep fan of this format so I guess I'll stick with it too. ;)

It's great to hear you'll try a workaround for using sound nodes generated from irredit. I guess you could create them and then open the .irr file to grab the sound code?

I got another question, but being it irrwrapper related, I'm sending it as a PM to you now.

regards,

Alvaro

Edit: I just tried sending you a PM and got this message:
Private messaging has been disabled on this board
So I dropped you a line at your hotmail address ;) Hope you can check it. Also double-check for my mail since it may be in your spam.
Frank Dodd
Posts: 444
Joined: Mar 10, 2006 19:22

Post by Frank Dodd »

Hi Alvaro,

There appears to be a case sensitivity error in the makefile, if you rename your irrKlang-1.1.3 folder to irrklang-1.1.3 it should build I think.

I have managed to build the IrrKlangWrapper on my linux machine but unfortunately the IrrKlang library does not support my version of GLib so I cant run it.

You can download my binary version of the wrapper from http://myweb.tiscali.co.uk/frankdodd/Ir ... 0.1.tar.gz
Last edited by Frank Dodd on Sep 11, 2010 8:13, edited 2 times in total.
afecelis
Posts: 85
Joined: Feb 20, 2009 22:34
Location: Colombia

Post by afecelis »

such a small detail, so gigantic consequences! :D
Nice you caught that one. Linux and its sensitiveness! ;)

I'll try it out on my next Linux boot.

cheers,
Alvaro
smashly
Posts: 4
Joined: Nov 15, 2010 13:23

Post by smashly »

Hi and thank you Frank for your irrKlang warapper.
I notice there's been no more updates on your irrKlang wrapper for a long while (I gather due to like anyone else, time is tight).
I've used your irrKlang wrapper with your irrLicht warapper in AutoIt scripting language and it's worked well, but I found that there's some functions that really could be used and have no idea how to implement them yet.
In the meantime I've adapted from your source and added around another 95+ functions.
From your old wrapper of 21 functions to my new version of your wrapper has 119 functions total and is based on irrKlang v1.3.0b .
I've not actually shared my version of your wrapper with anyone yet as I'm still writing the chm help file with examples for AutoIt scripting language.
I've managed to implement (All) Audio Recorder, (All) Device Lists, (All) Effects, (Most of) Engine, (All) Sound Source and (All) Sound functions.

Things I have no clue to implement, but would like to are:
ISoundStopEventReceiver;
For registerng when a sound stops.
ISoundMixedOutputReceiver;
For creating and Oscillograph or similar of a playing sound.
ICapturedAudioDataReceiver;
For creating a custom handled recorder buffer and or oscillograph or similar of a recording sound.

I'm just not sure about how to handle the callback of the receiver part of any of the above 3 to add to the wrapper.
If you could find the time to update your wrapper with any 1 of the the above 3 it would be appreciated greatly.
Then I could update my version of your wrapper with the other 2 ..lol

Edit: NVM I worked out the Audio recorder receiver part for the wrapper.
So now I'll be able to complete the other 2 into the wrapper as well. all good.

All the best and cheers.
P.S. Offtrack: really looking forward to your next official release of irrLicht wrapper.
Frank Dodd
Posts: 444
Joined: Mar 10, 2006 19:22

Post by Frank Dodd »

Hi Smashly,

Its good to hear that your problem is solved and I'm surprised that you could stuff so many new functions into it! The more the merrier though it will be very interesting to see the API.

As you guessed spare time is tight and to be honest the interest in IrrKlangWrapper has been too low to justify expending too much time on it possibly because the IrrKlang Library the wrapper is based on is a commercial library. Good luck with the wrapper extensions.
smashly
Posts: 4
Joined: Nov 15, 2010 13:23

Post by smashly »

Hi again,
Here's a list of all working exports to date that the wrapper has.
I think my logic to naming convention could be improved greatly.
But I found it easier to break the functions into groups since some functions have 3 types, eg: Sound Volume for the engine, sound and sound source are provided and the slight name change between the 3 left a new user guessing which to use.
Same for Get/Set Max/MinDistance and a few other functions alike.
So my logic was:
ISoundEffectControl->someEffect means it's an EfectSomeEffect function
ISoundEngine->doSomething means it's an EngineDoSomething function
ISound-->doSoundthing means it's a SoundDoSoundthing function
ISoundSource->doSource means it's a SourceDoSource function
IAudioRecoreder->doRecord means it's a RecorderDoRecord function
etc...
The function naming convention may be changed in the near future.

Code: Select all

    EffectDisableAllEffects @1
    EffectDisableChorus @2
    EffectDisableCompressor @3
    EffectDisableDistortion @4
    EffectDisableEcho @5
    EffectDisableFlanger @6
    EffectDisableGargle @7
    EffectDisableI3DL2Reverb @8
    EffectDisableParamEq @9
    EffectDisableWavesReverb @10
    EffectEnableChorus @11
    EffectEnableCompressor @12
    EffectEnableDistortion @13
    EffectEnableEcho @14
    EffectEnableFlanger @15
    EffectEnableGargle @16
    EffectEnableI3DL2Reverb @17
    EffectEnableParamEq @18
    EffectEnableWavesReverb @19
    EffectIsChorusEnabled @20
    EffectIsCompressorEnabled @21
    EffectIsDistortionEnabled @22
    EffectIsEchoEnabled @23
    EffectIsFlangerEnabled @24
    EffectIsGargleEnabled @25
    EffectIsI3DL2ReverbEnabled @26
    EffectIsParamEqEnabled @27
    EffectIsWavesReverbEnabled @28
    EngineAddSoundSourceAlias @29
    EngineAddSoundSourceFromFile @30
    EngineAddSoundSourceFromMemory @31
    EngineAddSoundSourceFromPCMData @32
    EngineGetDefault3DSoundMaxDistance @33
    EngineGetDefault3DSoundMinDistance @34
    EngineGetDriverName @35
    EngineGetSoundSourceByIndex @36
    EngineGetSoundSourceByName @37
    EngineGetSoundSourceCount @38
    EngineGetSoundVolume @39
    EngineIsCurrentlyPlayingName @40
    EngineIsCurrentlyPlayingSource @41
    EngineIsMultiThreaded @42
    EngineLoadPlugins @43
    EnginePlay2DName @44
    EnginePlay2DSource @45
    EnginePlay3DName @46
    EnginePlay3DSource @47
    EngineRemoveAllSoundSources @48
    EngineRemoveSoundSource @49
    EngineRemoveSoundSourceByName @50
    EngineSetAllSoundsPaused @51
    EngineSetDefault3DSoundMaxDistance @52
    EngineSetDefault3DSoundMinDistance @53
    EngineSetDopplerEffectParameters @54
    EngineSetListenerPosition @55
    EngineSetRolloffFactor @56
    EngineSetSoundVolume @57
    EngineStart @58
    EngineStop @59
    EngineStopAllSounds @60
    EngineUpdate @61
    ListCreateAudioRecorderDeviceList @62
    ListCreateSoundDeviceList @63
    ListDrop @64
    ListGetDeviceCount @65
    ListGetDeviceDescription @66
    ListGetDeviceID @67
    RecorderAddSoundSourceFromRecordedAudio @68
    RecorderClearRecordedAudioDataBuffer @69
    RecorderCreateAudioRecorder @70
    RecorderDrop @71
    RecorderGetAudioFormat @72
    RecorderGetDriverName @73
    RecorderGetRecordedAudioData @74
    RecorderIsRecording @75
    RecorderSaveRecordedAudio @76
    RecorderStartRecordingBufferedAudio @77
    RecorderStopRecordingAudio @78
    SoundDrop @79
    SoundGetIsPaused @80
    SoundGetMaxDistance @81
    SoundGetMinDistance @82
    SoundGetPan @83
    SoundGetPlayLength @84
    SoundGetPlayPosition @85
    SoundGetPlaybackSpeed @86
    SoundGetPosition @87
    SoundGetSoundSource @88
    SoundGetVelocity @89
    SoundGetVolume @90
    SoundIsFinished @91
    SoundIsLooped @92
    SoundSetIsLooped @93
    SoundSetIsPaused @94
    SoundSetMaxDistance @95
    SoundSetMinDistance @96
    SoundSetPan @97
    SoundSetPlayPosition @98
    SoundSetPlaybackSpeed @99
    SoundSetPosition @100
    SoundSetVelocity @101
    SoundSetVolume @102
    SoundStop @103
    SourceForceReloadAtNextUse @104
    SourceGetAudioFormat @105
    SourceGetDefaultMaxDistance @106
    SourceGetDefaultMinDistance @107
    SourceGetDefaultVolume @108
    SourceGetForcedStreamingThreshold @109
    SourceGetIsSeekingSupported @110
    SourceGetName @111
    SourceGetPlayLength @112
    SourceGetSampleData @113
    SourceGetStreamMode @114
    SourceSetDefaultMaxDistance @115
    SourceSetDefaultMinDistance @116
    SourceSetDefaultVolume @117
    SourceSetForcedStreamingThreshold @118
    SourceSetStreamMode @119
As for my receiver problem I hit a stability issue while passing data/length through a callback..doh
All works well until I do other things on the pc.
eg; Start recording and the buffer data gets passed from the wrapper to my script, but if I open media player while recording then my script has unexpected behavior after a short time..
I gather it's a timing issue between the wrapper and how quick my script can accept the next callback data or maybe just bad implementation of the receiver in the wrapper on my part or just the old hardware or drivers I'm writing and testing on, still testing further before keeping it in.
Unrelated but it's not easy to test 3D functions properly either when my onboard sound doesn't support hardware 3DBuffers..lol
Ohh well 17 more function help file examples to write an I'm upto speed for the time being.

All the best and until next time
Cheers.
Post Reply