Thread: Wav edit programmation for dos with DJGPP

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    2

    Wav edit programmation for dos with DJGPP

    My name is Steve Prud'Homme, I am a fan of DJGPP, it's a good free compiler... But I wan't some informations about wav manipulation with C and DJGPP... in dos(without windows) I no that Allegro is a good library for playing .wav files, but does Allegro have the ability to edit wav file... manipulate wav file, treat wav file with effect?

    It is possible to apply effect on a .wav file but without a soundcard, just mathematicly or with algorythm? I no that some old wav editor can do that. Where can i find information about wav manipulation programming with C or ASM. Witch library can i use with DJGPP? Free or commercial library?

    My goal is to program a command line wav editor that can treat, manipulate, edit wav file without a sound card in dos(without windows API or DirectX)

    Thanks a lot

    Steve Prud'Homme
    Don't look my english I'm french

    French translation:

    Bonjour, mon nom est Steve Prud'Homme, je suis un fan de DJGPP, c'est un bon compilateur gratuit. Mais j'aimerais avoir des information sur la programmation de manipulation de fichier wav en C ou ASM avec DJGPP... en Dos. Je sais qu'Allegro est une librairie capable de jouer des fichiers wav. Mais est-ce qu'elle est capable de les éditer, de les manipuler, de les traiter avec des effets?

    Est-ce que c'est possible d'appliquer un effet sur un wav sans carte de son, juste mathématiquement ou avec un algorythm? Je sais que certain vieux éditeursde wav en était capable! Ou est-ce que je peux trouver de l'information sur la manipulation de fichiers wav en C ou ASM? Quelles librairies dois-je choisir? Une gratuite ou commercial?

    Mon but est de programmer un éditeur de fichier wav qui peut traiter, éditer et manipuler un fichier wav sans carte de son en dos plein ou protégé mais sans window.

    Merci Beaucoup

    Steve Prud'Homme

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    As far as I know, you only need a sound card (preferably) to hear the results. All the editing and transformations happen in software.

    True. DOS sound cards do not allow for much - they simply play the end result of all your transformations to the sounds. Multiple channels of sound is an illusion - there in only one master track playing. Sort of like a mixer in a studio. It takes all the vocals, guitars, and keyboard tracks and mixes them into one master track - then to the amp - then to the mains. You must write this 'mixer' in software. Additive mixing works rather well for starters.

    For additive mixing simply add up all of the sound values at the same slice in time, divide by the number of sounds and put that result into the main mix. It does suffer from certain problems but it gives relatively good results for starters.

    Code:
    int result=0;
    int samplepos=0;
    for (int i=0;i<length;i++)
    {
      for (int soundnum=0;soundnum<numsamples;soundnum++)
      {
        if (samplepos<Sample[soundnum].BufferLength)
          result+=Sample[soundnum].Buffer[samplepos];
      }
      result/=numsamples;
      if (result<0) result=0;
      if (result>65535) result=65535;
      MainMix->Buffer[i]=result;
      samplepos++;
    }

    The structure for MainMix and Sample are for you to decide on. I did not provide them because it would only serve to confuse you.
    My advice is to use a linked list of sounds, that way when you overrun one sample's buffer - have come to the end of the sound it will not be in the main mix. Therefore it is a waste of time to check what value is in its buffer since the sound is done playing. Remove it from the list. This allows your mixer to perform better.
    I used arrays above which is ok, but has problems of its own.

    Notice that it would be very easy to play these samples in reverse by simply iterating through the samples from the end to the beginning rather than beginning to end. But each sample is not the same length so you would have to check where the end of sample was and then make sure that when you reach 0, you remove the sample from the playlist.

    Each sample above represents one channel of sound. To create looping sound simply create a LoopSound class or something with a flag in it to indicate that this sample will never be removed from the playlist. When it ends, just reset the samplepos to the beginning of the sound and it will repeat.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Subclassed edit not doing what it's supposed to
    By tyouk in forum Windows Programming
    Replies: 8
    Last Post: 01-21-2005, 10:25 PM
  2. newbie to rich edit, cant get it to work
    By hanhao in forum Windows Programming
    Replies: 1
    Last Post: 03-24-2004, 10:54 PM
  3. Window closes when edit is made
    By eam in forum Windows Programming
    Replies: 7
    Last Post: 11-06-2003, 09:11 PM
  4. Edit Control problem
    By Malek in forum Windows Programming
    Replies: 3
    Last Post: 06-16-2002, 01:12 AM
  5. Difficulty superclassing EDIT window class
    By cDir in forum Windows Programming
    Replies: 7
    Last Post: 02-21-2002, 05:06 PM