Author Topic: effects using samples?  (Read 2778 times)

kchabot

  • Guest
effects using samples?
« on: 15 Jun '03 - 23:10 »
Hi,

I need to apply DX effects to playing samples.
I cannot use streams since the samples should be behaving
like poly. midi notes...
(for example like in a drum computer)

How can I apply effects? I always get a handle error while
the handle is correct :s

Ian @ un4seen

  • Administrator
  • Posts: 21991
Re: effects using samples?
« Reply #1 on: 16 Jun '03 - 13:40 »
DX effects are not possible with samples. The reason is that when you play a sample multiple times, it's the same sample data being played - ie. there's only one copy of the data in memory, as you would expect (it'd be wasteful having copies of the same data). So it'd not be possible to apply an effect to just one of them.

You should still be able to achieve what you want using a load of (pre-buffered for minimum latency) streams :)

The best (but not simple :)) thing though would probably be to do your own mixing, and play the mix(es) via custom streams (applying the effects you want to those streams)... for example, you could mix all instances of a particular sample, assuming you want the same effects to apply to all instances of that sample.

If you go down the "you own mixing" road, and if the sound should be "realtime" (ie. the user presses a key, and the sound is heard), then you'll probably want to reduce the buffer length and update period, to reduce the latency... see the SYNTH example.

kchabot

  • Guest
Re: effects using samples?
« Reply #2 on: 16 Jun '03 - 14:58 »
So I could either use a decoding channel and mix myself, or
apply the effects on a sample and load the custom sample afterwards...

What should i choose :s... :)

kchabot

  • Guest
Re: effects using samples?
« Reply #3 on: 16 Jun '03 - 15:40 »
Another related question...

I'm using VB...
How can I write an array of integers (representing the data of the wave) to a created sample handle?
I'm trying to use copymemory etc... but I can't get it working...

kchabot

  • Guest
Re: effects using samples?
« Reply #4 on: 16 Jun '03 - 16:06 »
Sorry,
no mather...

I just forgot the ByVal option :)

Ian @ un4seen

  • Administrator
  • Posts: 21991
Re: effects using samples?
« Reply #5 on: 16 Jun '03 - 22:43 »
Quote
So I could either use a decoding channel and mix myself, or
apply the effects on a sample and load the custom sample afterwards...

What should i choose :s... :)

You forgot the "load of streams" option :)

I think that would probably be the best/simplest option for you - basically, just use streams instead of samples. When I say "pre-buffered", I mean call BASS_StreamPreBuf in advance of playback, so that the stream is "ready to go" (like a sample) and latency is minimised.

It really depends on what you're doing with the samples... for example, are you playing them at varying rates/pitches? If so, you'ld have to implement resampling if you did your own mixing, which can be quite complicated. VB isn't really ideal for doing that efficiently either. If the samples are all played at the same rate, then you could give mixing it yourself a go, but otherwise I wouldn't suggest it, unless you're familiar with it (or like headaches :D)

I guess that "apply the effects on a sample and load the custom sample afterwards" method you mention could also work, if you don't need to be able to change effect parameters.

kchabot

  • Guest
Re: effects using samples?
« Reply #6 on: 17 Jun '03 - 13:35 »
I tried many many methods...
And everytime, there was something wrong with it... No general effects, sample to short, no sounds playing over each other, to long load time, etc...

The only way to do this correctly is, indeed, by resampling the wave before mixing each time and then mixing them all tougether... *sigh*

I think i'll restart with this program in c when i find the time *g* not right now, seems a little to complicated at the moment ;)...