![]() |
|
|||||||
| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Additional Libraries Users contributed libraries. This sub-forum is only available to licensed users. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi. I've done it! You are now able to create fast action games with some awesome sound effects that you have full control over while they play or even before and after they play! This library works now 100% with Basic4ppc for both the desktop and the device! You can mix up to 64 MODS with the library and 128 waves all at once or whenever you see fit! The library has a completely new interface and only requires 2 files each for the desktop or the device, not 3 like in the previous version. It also now works with the Optimized Compiler for v6.01. I also did away with the manual and put an example program that shows how you can use this library in your own Basic4ppc apps. You can download the library here:
http://www.BrailleSoft.net/Hekkus.zip Enjoy and let me know what you think! Last edited by Louis : 12-28-2007 at 11:56 PM. |
|
|||
|
This looks very interesting, just what my version of Lunar Lander needs some rocket noises!
Im going to try it later, anyone know any good sources for wave files that sound like a rocket engine? Last edited by colin9876 : 12-02-2007 at 05:51 PM. |
|
|||
|
Hi. It sure is, here's an example using only 1 sound, however you can use as many sounds as you like.
'Add a reference to HSSNetDesktop for the Desktop or HSSNetDevice for the PPC and Smartphones. Add a Speaker objet called speaker, a Sound object called sound1, and a Channel1 object called channel1. You must add a sound object and a channel1 object per everysound you want to load and manipulate from Basic4ppc. Sub Globals End Sub Sub App_Start speaker.new1 sound1.new1 channel1.new1 Speaker.Open(44100, 16, true, 0, 16) 'The parameters of the Open() function are from left to right: Hurtz as Int32, 8 or 16 as Int32 for 8-bit or 16-bit files, stereo or mono as boolean true=stereo, Number of channels to allocate for MODS as Int32, and Number of channels to allocate for wavs as Int32. sound1.load("FileToLoad.wav") 'Loads a wav file into sound1. 'Now to manipulate the sound as it plays, you'd code: channel1.Value = speaker.channel(speaker.PlaySound(sound1.Value)) 'And to freeze the program until a sound is done playing, use the channel1 object. The channel1 class also has some nice methods that let you control the sound while it plays and such. The class entitled Channel doesn't work with Basic4ppc, so Channel1 allows this. 'Anyway, simply code while the sound is playing: do while channel1.Playing 'Code can go here while the sound plays if necessary. DoEvents loop 'When the sound is done the code after the loop executes. 'Don't forget to add a close event that closes the speaker when your program aborts via a call to speaker.close End Sub If anyone has more questions please let me know. HTH. |
|
||||
|
Hello Louis,
Thank you for your answer. You say that I must add a sound object and a channel1 object per everysound you want to load and manipulate from Basic4ppc. In my app, I have to play 99 different wav files (1.wav 2.wav ... up to 99.wav) I've done a sub to do that : Code:
sub tell(num)
Sound (".\sons\" & num & ".wav")
Sleep (1200)
End Sub
speaker.new1 sound1.new1 channel1.new1 Another question : is it possible with your lib to play mp3 files ? Thank you.
__________________
Pascal |
|
|||
|
Hi Pascal, As of now the lib doesn't support mp3's, only MODS and wavs. And there is a way to load sounds quickly as long as your files are numbered. Check out this code:
'Add a Speaker object named Speaker using Tools - Add Object after making a reference to HSSNETDesktop or HSSNETDevice.dll Sub Globals End Sub Sub App_Start speaker.New1 speaker.open(44100, 16, true, 0, 16) 'And now let's get the sounds we want. for i = 1 to 99 AddObject("sound" & i, "Sound") 'Without the optimized compiler: control("Sound" & i).New1 'With the optimized compiler maybe: control("Sound" & i,Sound).New1 AddObject("Channel" & i, "Channel1") 'Without the optimized compiler: control("Channel" & i).New1 'With the optimized compiler maybe: controll("Channel" & i,Channel1).New1 'Then load the sound. 'Without the optimized compiler: control("Sound" & i).load("File" & i & ".wav") 'with the optimize compiler maybe: control("Sound" & i,Sound).load("filename" & i & ".wav") next 'Now you can play whatever sound you like! Here is code that'll play a random sound for you, and assign the channel to it in case you want to mod it while the sound plays. a = rnd(1, 100) 'Without the optimized compiler code: control("Channel" & a).Value = speaker.channel(speaker.playSound(control("Sound" & a).Value)) 'With the optimized compiler you might have to code: control("channel" & a,Channel1).Value = speaker.channel(speaker.playSound(control("Sound" & a,Sound).value)) 'If you want to modify the sound, use any of the methods in the Channel1 class to do so. 'Don't forget to add a close event to the form that calls speaker.close before your app ends! End Sub Please note: Hekkus loads and compresses sounds into memory so they'll play as soon as you call speaker.PlaySound(). Because you have 99 sounds loading, this may take about 30 seconds or less depending on how big the files are, and how fast your device is. The desktop loads files wihin seconds so there is no delay there because of how fast the processors are. If you have more questions please let me know. HTH. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| The Hekkus Library doesn't work when used with the Optimized Compiler | Louis | Questions & Help Needed | 5 | 12-28-2007 08:06 PM |
| SOund Input? | PKinz | Basic4ppc Wishlist | 1 | 12-12-2007 02:51 PM |
| Controlling Sound | derez | Questions & Help Needed | 0 | 10-28-2007 08:14 PM |
| Hekkus Sound System wrapper | Louis | Additional Libraries | 18 | 09-27-2007 12:35 PM |
| Sound/Mic input | Bill Todd | Questions & Help Needed | 2 | 06-22-2007 11:29 AM |