Solved

Mixing Wav's Component (2 channels !!)

Posted on 1998-08-02
6
320 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi - replicating a form 8 112
Printing problem 2 124
Working with hours 3 89
Using MMsystem To change audio input 1 40
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 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