Multichannel sounds

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by mindplay.

The current Sound-commands are great for example for an engine sound - you can start it, let it loop continously, and change the panning, volume, and pitch as you please. However, this system is really bad for example for explosions, since only one instance of any given sound can be played at the same time, so the next explosion always abruptly cuts off the previous one, which sounds really bad.

I propose a new command to solve this problem:

SoundChannels(#Sound, MaxVoices)

So if you set for a maximum of, say, four channels, for your explosion sound effect, up to four instances of the explosion can play simultaneously, when you call PlaySound again and again.

SoundFrequency, SoundPan and SoundVolume should be modified, so that when they're used with a sound that has been set to more than one voice, these settings will count for the NEXT sound that gets triggered with PlaySound, NOT the current one - this will enable you to trigger explosions in the left and right speakers, for example, without panning explosion sounds that are already playing as well.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.

Use DirectSound, you will be able to do that and more (Add effects that will give your sounds a lot of possibilities to make it real!!).

I dont know how to use it from PB. I have use it from VB and its great.

Best Regards

Ricardo

Dont cry for me Argentina...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by mindplay.

Yeah, but VB has a nice, simplified, basic-friendly DirectSound encapsulation - of course if we had that in PB, I'd be using that, but using DirectSound itself is more than I can manage ... if I knew how to do that, I'd be programming C++ instead :)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

For now, you can load several time the sound (not optimal, but it will do it). Your channel solution seems nice, or I could make it automatically. I will take a closer look to the sound library now.

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by vanleth.

Agree with Mindplay. Multichannels "sounds" like a feature every decent game would use.

Van
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

Nice, so it would be possible to write own tackers for example, like good old ProTracker, DigiBooster, OctaMed, FastTracker and co? :wink:

greetz
MrVainSCL! aka Thorsten

PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX9.0, SB AWE64, Win2000 + all Updates...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

MrVain:
You can already write Trackers and more by using
http://www.FMOD.org (with http://home.t-online.de/home/ExpressTrack/PureFMOD.zip) and if you want you can
also use your MIDI output like i did in my little
http://home.t-online.de/home/ExpressTrack/Sequencer.zip (for fun only :))

cya,
...Danilo
(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

Danilo, when i wrote to write own trackers... i dont mean any available player routines like FMod or whatever... i mean, to code an own replayer rouitine and plaing samples with PlaySound() for example... I know that Midi works too... but i really mean to have a complete own format (would be interesting for me to code such a tool - even if its a simple tool without much features) :wink:


greetz
MrVainSCL! aka Thorsten

PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX9.0, SB AWE64, Win2000 + all Updates...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by mindplay.

Ricardo,

You wouldn't be able to make a tracker with PlaySound commands - you wouldn't be able to get any control over the timing of played sounds. Only with a buffersize small enough, you might be able to get barely acceptable note timing, but you also cannot manually adjust the buffersize, so that wouldn't work either.

The only way you could make a tracker, with proper timing, is if a DirectSound interface was provided, with a callback in which you could manually resample and mix samples directly into the buffer, but such an interface is not available. I'm very interrested in this myself, and have attempted to make a PB interface for PortAudio (http://www.portaudio.com), but I can't get this to work at all - I've ported most of the BASS library to PB by now though, that would make it possible as well, but you also have no control over buffers or latency with BASS, and it only works with DirectSound, so it's really only half a solution.

The easiest path to making it possible to write real music software in PB, would be an interface port, and precompiled DLLs, for PortAudio - but I've given up trying to do it myself, I simply don't know how to...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

> Danilo, when i wrote to write own trackers... i dont mean any available player
> routines like FMod or whatever...

I understood. I ment not to use FMOD for playing complete MODs.
FMOD has also functions to play a WAV, MP3, whatever... - so you
can use it like PlaySound() for samples, but use more Formats.

> i mean, to code an own replayer rouitine and plaing samples
> with PlaySound() for example...

You could write your own MOD-Format (.vain :)) and for
the internal samples you could use WAV, MP3, OGG Vorbis
and all this...

> (would be interesting for me to code such a tool -
> even if its a simple tool without much features) :wink:

I only wanted to say "you can already do this if you
use 3rd party music systems".
PureBasic provides basic sound playing routines, but
FMOD is a complete music & sound effects system.
You can add your own effects and callbacks for sound buffer
manipulation and all... just a hint.
FMOD is free for writing freeware, so you could use it now.
If your tracker becomes bigger and you want to sell it as
shareware you have to pay only $100 for FMOD - not a problem
if you sell good shareware.

Its like "do it NOW by using FMOD/BASS/whatever or wait
and wait and wait... MAYBE you can do it with PB later."

Your choice - druschba. :)

cya,
...Danilo
(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by mindplay.

except for programming experience though, it would seem rather pointless to write another purely sample-based tracker? it's not like there isn't enough of those, and they basically all do the same thing ... and there's no need to invent a new format for something that there is already a very widely used format for. I don't want to put you off or anything :) ... but if you want to write music software for than just the experience, you should write something that isn't already available everywhere, standardized, and free.

All modern trackers have plugin support, synthesis and effects features, which is not something you could implement with FMOD (probably?) because it requires custom buffer rendering routines - with BASS, you could, but as said, the interface is very limited, since it does not allow you to adjust latency, for example, and that's a must in modern music software.

I'm sure PB would be great for writing music software - as said, I'd like to do that myself, but as long as the basic building blocks aren't there, I just don't see much point in bothering :/ ... even if I did end up with some software with some nice features and a nice interface, it would still be crippled by the non-support for custom latency settings and professional audio interfaces (i.e. ASIO) ...

Although, it's only really the output stream that I'm talking about here - the transport of the rendered audio buffers to the soundcard, via MME/DirectSound/ASIO ... I suppose if I did manage to write some software, I could always hope that such interfaces would be available at the time what I finished - just seems pretty risky to invest a lot of work in it, and then get stuck just before the finish line! :wink:
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by mindplay.

whoa! well, would you look at that? :) ... I had not actually looked at FMOD since over a year, and now that I take a look, what do I see? it DOES support ASIO on Windows! it even supports full duplex recording and custom streams and everything! I'm going to have to take a closer look at this! :)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

mindplay :)

cya,
...Danilo
(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

hi mindplay...
its just only interested to learn how to code a tracker and the mainpoint is to have an own replayer (!!) included to the exe where the replayer incl. song(tracker) data and samples as small as possible... i would try it first with any empty 4channel mod, and then i would begin step by step to produce my own (very small optimized) format... All i would like to code, is also an own replayer with very small data for complete tune and to precalculate samples :wink: - even for small games and other stufff... but i know, its a long way :wink:


greetz
MrVainSCL! aka Thorsten

PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX9.0, SB AWE64, Win2000 + all Updates...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by mindplay.

I mean, yeah .. if you really think you can beat the size of FMOD (120 KB for the player) and the extremely small size of XM songs with ogg-vorbis-compressed samples ... good luck :wink:
Post Reply