Mail Archives: djgpp/2000/01/30/09:10:34
From: | "Osah" <osah AT geneva-link DOT ch>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re:Re: Allegro Program Problem (Pleeasse Hellp me Somebody :-( )
|
Date: | Wed, 26 Jan 2000 20:38:14 +0100
|
Organization: | sunrise communications ag
|
Lines: | 112
|
Message-ID: | <86nia6$g03$1@news1.sunrise.ch>
|
NNTP-Posting-Host: | pop-ls-07-1-dialup-83.freesurf.ch
|
X-Trace: | news1.sunrise.ch 948915334 16387 194.230.232.83 (26 Jan 2000 19:35:34 GMT)
|
X-Complaints-To: | usenet AT sunrise DOT ch
|
NNTP-Posting-Date: | 26 Jan 2000 19:35:34 GMT
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Newsreader: | Microsoft Outlook Express 5.00.2314.1300
|
X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2314.1300
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
I forgot the code, so here it is:
I wrote a program with allegro to get input from the microphone from the
user and output it to the speakers at the same time, but i don't seem to be
getting the desired results from either the microphone or speakers. Below
are the code listings (Sorry if it is too long):
/*
* Example program for the Allegro library, by Cable_TXG.
*
* This program shows how to use the audio recording functions.
*/
#include <stdio.h>
#include "allegro.h"
int main(void)
{
void *rec_buffer;
int rec_bits=0; // What type of supported Sample from Audio input...
int rec_stereo=0; // Are we capable to record in stereo mode?
int rec_rate=0; // Maximum possible recording frequency.
int user_rate = 0;
int rec_parm=0; // Recording Parameter supported by Audio Driver?
int buffer_size, data_ready=0;
allegro_init();
install_keyboard();
install_timer();
/* install a digital sound driver */
if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0)
{
printf("Error initialising sound system\n%s\n", allegro_error);
return 1;
}
/* Initialize the sound recorder module */
if (install_sound_input(DIGI_AUTODETECT, MIDI_NONE) != 0)
{
printf("Error initialising sound recoder module.\n%s\n",
allegro_error);
return 2;
}
if ((rec_bits = get_sound_input_cap_bits()) == 0)
{
printf("Audio input not supported.\n");
return 3;
}
rec_stereo = get_sound_input_cap_stereo();
rec_rate = get_sound_input_cap_rate(rec_bits, rec_stereo);
printf("Maximum recording frequency: %d\n",rec_rate);
// printf("Enter your choice: "); // Get recording frequency from user
user_rate = rec_rate;
// while(1)
// {
// scanf("%d",&user_rate);
// fflush(stdin);
// if((user_rate > 0) && (user_rate <= rec_rate))
// break;
// }
rec_parm = get_sound_input_cap_parm(user_rate,rec_bits,rec_stereo);
switch(rec_parm)
{
case 0: printf("Impossible to record at this rate.\n");
return 4;
case 1: printf("Recording is possible, audio output suspended.\n");
break;
case 2: printf("Recording/Playing supported\n");
break;
default: printf("Not supported, try rate: %d\n",rec_parm);
break;
}
if (set_sound_input_source(SOUND_INPUT_MIC) == -1)
{
printf("Input Select Register not provided by Hardware.\n");
return 5;
}
printf("Press any key to end recording....\n");
buffer_size = start_sound_input(user_rate, rec_bits, rec_stereo);
if(buffer_size == 0)
{
printf("Error in sound input: %s",allegro_error);
return 5;
}
rec_buffer = (void *)malloc(buffer_size);
while(!keypressed())
{
data_ready = read_sound_input(rec_buffer);
if(!data_ready)
printf("No new Data yet...\n");
}
stop_sound_input();
printf("Thanks for using this test program....\n");
free(rec_buffer);
allegro_exit();
return 0;
}
Please send any answers to me as well as this NG.
Thanks.
- Raw text -