Solved

Mixing Wav's Component (2 channels !!)

Posted on 1998-08-02
6
307 Views
Last Modified: 2010-04-03
Hello,
I am searching the WEB for a component which can help me by making a project to mix two WAV-files. For example, I have found such a component (Component-name: "Delphi WaveMix v1.21" at http://www.digiserve.com/cmab) for 8 channels, but the sound-quality is too bad, even when I mix only two channels at the same time. Please help me to find such a (free !!) component for only 2 channels with a much better soundquality. Thanx very much!!! These many points (200!!) are only for a really good working component. By the way: I am using Delphi 3.
J.v.Barchum.
0
Comment
Question by:roosiedb
  • 2
  • 2
  • 2
6 Comments
 
LVL 3

Expert Comment

by:Matvey
ID: 1359530
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1359531
Hi roosiedb, the latest version of this component is v2.0, maybe it's renewed? Zif.
0
 

Author Comment

by:roosiedb
ID: 1359532
Both components (dwavemix.zip I allready had found myself, see my question) do not have the quality I want them to have... So that's why I asked for a better component. The components I have found myself have to same quality as a short-wave-radio...!!
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 3

Expert Comment

by:Matvey
ID: 1359533
I have found sources of a sample module player application. If you can understand how it works (written in C), you will understand how you can play some sounds at the same time.
Leave your email if you want to take a look.
bosism@netvision.net.il
0
 

Author Comment

by:roosiedb
ID: 1359534
I'm sorry, it has to be in Delphi because I don't understand C or C++ at all.
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 200 total points
ID: 1359535
It's in explained in a previous UNDU :

----

Digital Sound in Delphi - Part II

by Stanislav Holenda - texmurphy@email.cz

As I promised in my previous article, I’m back with more Delphi sound stuff. Today we shall look at possibilities of producing multi-channel
sound effects. First of all we should theoretically discuss how to play two samples at one time on one sound device - this bring us to:

Mixing the Samples

Windows has ability to play sounds (I call them samples) by "itself", but when you want to, for example, play digital music together with sound
FX (like clicking sounds on buttons, ...) you have a hard choice - to play music or sounds?

Well if you want to play them both, you’ll have to mix them. Mixing of samples with same sample rate (frequency) is fairly easy - you just have to
calculate average value of their current values:

If you have stored your sample in array like this (let’s assume they are 8-bit mono, <64kB):

     type
       Tsample = array[0..65520] of byte;
     var
       samples : array[1..4] of ^Tsample;

You will mix them like this:

     value:= (samples[1]^[ppos] + samples[2]^[ppos] + samples[3]^[ppos] + samples[4]^[ppos]) div 4;

In the ppos variable is stored the playing position, and the return value is the current value to be send to the DAC. A bit harder is when you must
play sample on different rates (when playing music, you’ll have to play the instrument sample on different rate to create accord, for example) -
you’ll have to choose the mixing rate which will be the frequency of sending data to DAC.

For example: Let’s assume we have mixing rate 11025 Hz (=11025 times per second, we will write to DAC) and want to play one sample on
11025 Hz and second on 22050 Hz. We will take each byte from first sample (play rate/mixing rate = step) and each second byte from second
sample (22050/11025=2) and mix them together and the output will be one sound playing two times faster than another. This is relatively easy to
understand but harder to make a mixing routine that is fast enough to keep up. To make a good mixing routine, you’ll have to think out an
optimized algorithm and write it in assembly language, if you're a tough programmer, or you can use the easy and simple interface of the MIDAS
Digital Sound System.

MIDAS Sound FX engine

I expect you are now either bored or confused from my previous paragraph full of theory and now you'd like to do something easy that works
well... Well here goes a step-by-step sound FX engine guide:

First of all you need to initialize MIDAS (best in the form.create method or in application startup), but slightly different as in previous article:

     midasStartup;
     midasInit;
     MIDASstartBackgroundPlay(100); {this orders MIDAS to poll the buffers 100 times/second}

Second open some channels for sound FX:

     MIDASopenChannels(5); {opens 5 channels}
     MIDASallocAutoEffectChannels(4); {allocates 4 for AUTO_CHANNEL mode (look below)}

Third load samples:

     var sample,sample2:MIDASsample;

     sample:=MIDASloadRawSample('explod11.snd',MIDAS_SAMPLE_8BIT_MONO,MIDAS_LOOP_NO);
     sample2:=MIDASloadWaveSample('laugh1.wav',MIDAS_LOOP_NO);

Fourth play them when you want:

     MIDASplaySample(sample,MIDAS_CHANNEL_AUTO,0,11025,63,MIDAS_PAN_MIDDLE);

'sample' is a variable of type MIDASsample which must point to some data loaded with MIDASloadWave/RawSample function.
MIDAS_CHANNEL_AUTO  commands MIDAS to select some free channel for playing the sample automatically. 0  this number is priority -
higher means higher priority
11025  play rate of sample (=the rate you want to sample at). 63 is the volume, and MIDAS_PAN_MIDDLE is the panning constants - you can
use constants or numbers in range -63..63 for panning from left to right.

Also this usage of PlaySample command will only play it, if you want also control sample properties during playback (rate, volume, panning)
you’ll have to use it like this:

     var laugh_handle:MIDASsamplePlayHandle;
     laugh_handle:=MIDASplaySample(sample2,MIDAS_CHANNEL_AUTO,0,11025,63,MIDAS_PAN_RIGHT);

And then use commands described in MIDAS help under "Controlling sample playback".

Fifth you must deallocate all samples, close sound device, and other stuff when you exit your program:

     MIDASfreeAutoEffectchannels; {deallocate AUTO_CHANNELS}
     MIDASfreeSample(sample); {free memory occupied by samples}
     MIDASfreeSample(sample2);
     {Note: MIDAS may remove samples automatically when midasClose is called, but I’m not sure}

     MIDASstopBackgroundPlay; {stop poll-playing}

     midasClose;

So this would be in brief how to use MIDAS sound mixing capabilities. Next time we might talk about echo-effects and post processor in
MIDAS and also samples & modules type and formats. If anybody got any questions about this article, or other sound-related problems let me
know.

You can get a copy of the source code for my demo application by clicking here, and you can also download the files for a minimal Midas
configuration, by clicking here.

--------

Regards, Zif.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now