First commit ~0,10
This commit is contained in:
27
WAVPLAV/CIRCUITO.ASC
Normal file
27
WAVPLAV/CIRCUITO.ASC
Normal file
@ -0,0 +1,27 @@
|
||||
Puerto de impresora:
|
||||
|
||||
se<73>al pin
|
||||
20k 20k
|
||||
D0 2 ><3E><>İ<EFBFBD><C4B0><EFBFBD><EFBFBD>İ<EFBFBD><C4B0><EFBFBD><EFBFBD> 0v (Tierra, pin 20)
|
||||
20k <20> 10k
|
||||
D1 3 ><3E><>İ<EFBFBD><C4B0>Ĵ
|
||||
20k <20> 10k
|
||||
D2 4 ><3E><>İ<EFBFBD><C4B0>Ĵ
|
||||
20k <20> 10k
|
||||
D3 5 ><3E><>İ<EFBFBD><C4B0>Ĵ
|
||||
20k <20> 10k
|
||||
D4 6 ><3E><>İ<EFBFBD><C4B0>Ĵ
|
||||
20k <20> 10k
|
||||
D5 7 ><3E><>İ<EFBFBD><C4B0>Ĵ
|
||||
20k <20> 10k
|
||||
D6 8 ><3E><>İ<EFBFBD><C4B0>Ĵ
|
||||
20k <20> 10k
|
||||
D7 9 ><3E><>İ<EFBFBD><C4B0>Ĵ
|
||||
20k <20> 10k 100nF
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>> Al amplificador
|
||||
<20> <20>
|
||||
<20> 10k <20> 10nF
|
||||
<20> <20>
|
||||
Tierra 20 ><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>
|
||||
0v
|
||||
|
30
WAVPLAV/DAC.CPP
Normal file
30
WAVPLAV/DAC.CPP
Normal file
@ -0,0 +1,30 @@
|
||||
#include <dos.h>
|
||||
|
||||
void InitDAC(void);
|
||||
void LPT1DAC(unsigned char b);
|
||||
void LPT2DAC(unsigned char b);
|
||||
|
||||
|
||||
unsigned LPT1Addr = 0x378,
|
||||
LPT2Addr = 0x278;
|
||||
|
||||
|
||||
void InitDAC(void)
|
||||
{
|
||||
unsigned *Addr;
|
||||
|
||||
Addr = (unsigned *)MK_FP(0x40,0x8);
|
||||
if (*Addr!=0) LPT1Addr = *Addr;
|
||||
Addr = (unsigned *)MK_FP(0x40,0xA);
|
||||
if (*Addr!=0) LPT2Addr = *Addr;
|
||||
}
|
||||
|
||||
void LPT1DAC(unsigned char b)
|
||||
{
|
||||
outportb(LPT1Addr,b);
|
||||
}
|
||||
|
||||
void LPT2DAC(unsigned char b)
|
||||
{
|
||||
outportb(LPT2Addr,b);
|
||||
}
|
3
WAVPLAV/DAC.H
Normal file
3
WAVPLAV/DAC.H
Normal file
@ -0,0 +1,3 @@
|
||||
void InitDAC(void);
|
||||
void LPT1DAC(unsigned char b);
|
||||
void LPT2DAC(unsigned char b);
|
BIN
WAVPLAV/DAC.OBJ
Normal file
BIN
WAVPLAV/DAC.OBJ
Normal file
Binary file not shown.
2
WAVPLAV/LIB.BAT
Normal file
2
WAVPLAV/LIB.BAT
Normal file
@ -0,0 +1,2 @@
|
||||
call setb
|
||||
tlib %1 +dac +sb +speaker +vocplay
|
1
WAVPLAV/P.BAT
Normal file
1
WAVPLAV/P.BAT
Normal file
@ -0,0 +1 @@
|
||||
play 3ge89.wav %1 %2
|
BIN
WAVPLAV/PLAY.DSK
Normal file
BIN
WAVPLAV/PLAY.DSK
Normal file
Binary file not shown.
BIN
WAVPLAV/PLAY.LIB
Normal file
BIN
WAVPLAV/PLAY.LIB
Normal file
Binary file not shown.
BIN
WAVPLAV/PLAY.PRJ
Normal file
BIN
WAVPLAV/PLAY.PRJ
Normal file
Binary file not shown.
57
WAVPLAV/SB.CPP
Normal file
57
WAVPLAV/SB.CPP
Normal file
@ -0,0 +1,57 @@
|
||||
#include <dos.h>
|
||||
|
||||
int SBDetect(void);
|
||||
void SBSendByte(unsigned char b);
|
||||
|
||||
/*
|
||||
Soporte de Sound Blaster
|
||||
*/
|
||||
|
||||
unsigned BPORT = 0x210,
|
||||
XPORT = 0x216,
|
||||
WPORT = 0x21C,
|
||||
RPORT = 0x21A,
|
||||
APORT = 0x21E;
|
||||
|
||||
char READY = 0xAA;
|
||||
|
||||
int SBDetect(void)
|
||||
{
|
||||
char Status,Ct;
|
||||
|
||||
Status = 0;
|
||||
while (Status!=READY && BPORT<0x270)
|
||||
{
|
||||
outportb(XPORT,1);
|
||||
outportb(XPORT,0);
|
||||
Ct = 0;
|
||||
while (Status!=READY && Ct<100)
|
||||
{
|
||||
Status = inportb(RPORT);
|
||||
Ct++;
|
||||
};
|
||||
if (Status!=READY)
|
||||
{
|
||||
BPORT += 0x10;
|
||||
XPORT += 0x10;
|
||||
WPORT += 0x10;
|
||||
RPORT += 0x10;
|
||||
APORT += 0x10;
|
||||
}
|
||||
}
|
||||
if (BPORT!=0x270)
|
||||
{
|
||||
while ((inport(WPORT) & 128) != 0);
|
||||
outportb(WPORT,0xD1);
|
||||
return(0);
|
||||
}
|
||||
else return(-1);
|
||||
}
|
||||
|
||||
void SBSendByte(unsigned char b)
|
||||
{
|
||||
while ((inport(WPORT) & 128) != 0);
|
||||
outportb(WPORT,0x10);
|
||||
while ((inport(WPORT) & 128) != 0);
|
||||
outportb(WPORT,b);
|
||||
}
|
2
WAVPLAV/SB.H
Normal file
2
WAVPLAV/SB.H
Normal file
@ -0,0 +1,2 @@
|
||||
int SBDetect(void);
|
||||
void SBSendByte(unsigned char b);
|
BIN
WAVPLAV/SB.OBJ
Normal file
BIN
WAVPLAV/SB.OBJ
Normal file
Binary file not shown.
65
WAVPLAV/SPEAKER.CPP
Normal file
65
WAVPLAV/SPEAKER.CPP
Normal file
@ -0,0 +1,65 @@
|
||||
#include <dos.h>
|
||||
|
||||
void InitSpeaker(void);
|
||||
void CloseSpeaker(void);
|
||||
void SpkSendByte(unsigned char b);
|
||||
|
||||
/*
|
||||
Rutinas de PWM para el altavoz interno del PC.
|
||||
*/
|
||||
|
||||
unsigned char TablaSpeaker[256] =
|
||||
{0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
|
||||
0x40,0x40,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
||||
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3E,0x3E,
|
||||
0x3E,0x3E,0x3E,0x3E,0x3E,0x3E,0x3E,0x3E,
|
||||
0x3D,0x3D,0x3D,0x3D,0x3D,0x3D,0x3D,0x3D,
|
||||
0x3D,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,
|
||||
0x3C,0x3C,0x3C,0x3B,0x3B,0x3B,0x3B,0x3B,
|
||||
0x3B,0x3B,0x3B,0x3B,0x3B,0x3A,0x3A,0x3A,
|
||||
0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x39,
|
||||
0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,
|
||||
0x39,0x38,0x38,0x38,0x38,0x38,0x38,0x38,
|
||||
0x38,0x37,0x37,0x37,0x37,0x37,0x36,0x36,
|
||||
0x36,0x36,0x35,0x35,0x35,0x35,0x34,0x34,
|
||||
0x34,0x33,0x33,0x32,0x32,0x31,0x31,0x30,
|
||||
0x30,0x2F,0x2E,0x2D,0x2C,0x2B,0x2A,0x29,
|
||||
0x28,0x27,0x26,0x25,0x24,0x23,0x22,0x21,
|
||||
0x20,0x1F,0x1E,0x1D,0x1C,0x1B,0x1A,0x19,
|
||||
0x18,0x17,0x16,0x15,0x14,0x13,0x12,0x11,
|
||||
0x11,0x10,0x10,0x0F,0x0F,0x0E,0x0E,0x0D,
|
||||
0x0D,0x0D,0x0C,0x0C,0x0C,0x0C,0x0B,0x0B,
|
||||
0x0B,0x0B,0x0A,0x0A,0x0A,0x0A,0x0A,0x09,
|
||||
0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,
|
||||
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
|
||||
0x08,0x08,0x08,0x08,0x07,0x07,0x07,0x07,
|
||||
0x07,0x07,0x07,0x06,0x06,0x06,0x06,0x06,
|
||||
0x06,0x06,0x06,0x06,0x06,0x06,0x05,0x05,
|
||||
0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,
|
||||
0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
|
||||
0x04,0x04,0x03,0x03,0x03,0x03,0x03,0x03,
|
||||
0x03,0x03,0x03,0x03,0x02,0x02,0x02,0x02,
|
||||
0x02,0x02,0x02,0x02,0x02,0x01,0x01,0x01,
|
||||
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01};
|
||||
|
||||
|
||||
void InitSpeaker(void)
|
||||
{
|
||||
asm CLI;
|
||||
outportb(0x43,0x90); /* Prepara el Timer 2: Acceso MSB y modo terminal */
|
||||
outportb(0x61,inportb(0x61) | 3); /* Hace que el speaker funcione con el timer 2 */
|
||||
asm STI;
|
||||
}
|
||||
|
||||
void CloseSpeaker(void)
|
||||
{
|
||||
asm CLI;
|
||||
outportb(0x61,inportb(0x61) & 0xFC); /* Para el altavoz */
|
||||
outportb(0x43,0xB6); /* Restaura el valor del registro de control del Timer 2 */
|
||||
asm STI;
|
||||
}
|
||||
|
||||
void SpkSendByte(unsigned char b)
|
||||
{
|
||||
outportb(0x42,TablaSpeaker[b]);
|
||||
}
|
3
WAVPLAV/SPEAKER.H
Normal file
3
WAVPLAV/SPEAKER.H
Normal file
@ -0,0 +1,3 @@
|
||||
void InitSpeaker(void);
|
||||
void CloseSpeaker(void);
|
||||
void SpkSendByte(unsigned char b);
|
BIN
WAVPLAV/SPEAKER.OBJ
Normal file
BIN
WAVPLAV/SPEAKER.OBJ
Normal file
Binary file not shown.
406
WAVPLAV/VOCPLAY.CPP
Normal file
406
WAVPLAV/VOCPLAY.CPP
Normal file
@ -0,0 +1,406 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <conio.h>
|
||||
|
||||
#include <alloc.h>
|
||||
#include <dos.h>
|
||||
#include <io.h>
|
||||
|
||||
#include "sb.h"
|
||||
#include "dac.h"
|
||||
#include "speaker.h"
|
||||
#include "Wavplay.h"
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
#define ERROR_ABRIENDO 2
|
||||
#define SIN_MEMORIA 3
|
||||
#define FICHERO_ENORME 4
|
||||
|
||||
char huge *pWav, /* Puntero a la digitalizaci<63>n */
|
||||
huge *pMuestra; /* Puntero a la muestra que suena */
|
||||
long Tamanyo, /* Tama<6D>o de los datos */
|
||||
T_Real;
|
||||
|
||||
unsigned
|
||||
Divisor, /* Valor del divisor del Timer 0 */
|
||||
Frec=11000; /* Frecuencia de muestreo */
|
||||
char FinVoz; /* Indica si la digitalizaci<63>n ha terminado de sonar */
|
||||
void interrupt (*Antigua8)(...); /* Antigua INT 8 */
|
||||
|
||||
void (*ByteAlDAC)(unsigned char); /* Puntero a la funci<63>n que env<6E>a el byte al DAC */
|
||||
|
||||
char Wav_Mem = 0, Init = 0, SB_SPK = 0, Old_File[80];
|
||||
|
||||
int CargaWav(char *Nombre, long Pos, long Len);
|
||||
void DeInitSB(void);
|
||||
int InitSB(void);
|
||||
|
||||
int Condicion_S00(void);
|
||||
|
||||
int PlayWav(char far *File, long Pos, long Len );
|
||||
|
||||
int PlayLongWav(char far *File, long Pos, long Len);
|
||||
|
||||
void ProgFrec(unsigned *Frecuencia);
|
||||
void interrupt Nuestra8(...);
|
||||
void ProgTimer0(unsigned Divisor);
|
||||
|
||||
//int far TeclaPulsada(void);
|
||||
|
||||
/*
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc<2)
|
||||
{
|
||||
printf("Error: falta par<61>metro necesario.\n");
|
||||
printf(" Fichero Salida\n");
|
||||
printf(" Salida --> 0 Speaker\n");
|
||||
printf(" --> 1 SB\n");
|
||||
printf(" --> 2 Dac\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
InitSB();
|
||||
|
||||
if ( argc == 3 ) SB_SPK = atoi(argv[2]);
|
||||
|
||||
|
||||
if ( PlayWav(argv[1],TeclaPulsada) != 0 )
|
||||
PlayLongWav(argv[1],TeclaPulsada);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
/* *//* *//**/
|
||||
/* *//* <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20> <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20> <20><><EFBFBD><EFBFBD> <20> <20> *//**/
|
||||
/* *//* <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20> <20><> <20><><EFBFBD><EFBFBD> <20> <20> <20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD> <20> <20> *//**/
|
||||
/* *//* <20><><EFBFBD> <20> <20> <20> <20><> <20><><EFBFBD><EFBFBD> <20> <20> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20> <20><><EFBFBD> *//**/
|
||||
/* *//* JD*//**/
|
||||
|
||||
int CargaWav(char *Nombre, long Pos, long Len)
|
||||
{
|
||||
FILE *handle_sonido;
|
||||
long tam = 0;
|
||||
|
||||
|
||||
if( Wav_Mem == 1 ) { farfree( pWav ); Wav_Mem = 0; }
|
||||
|
||||
if((handle_sonido = fopen(Nombre, "rb"))==NULL) {
|
||||
return ERROR_ABRIENDO;
|
||||
}
|
||||
|
||||
if( (Tamanyo =
|
||||
( (Len==-1) ?
|
||||
filelength(fileno(handle_sonido))-32
|
||||
:
|
||||
Len - 32
|
||||
)
|
||||
) < 1 ) { T_Real = 0; return ERROR_ABRIENDO; }
|
||||
|
||||
fseek( handle_sonido, Pos, SEEK_SET );
|
||||
|
||||
T_Real = Tamanyo;
|
||||
|
||||
if ( (pWav = (char huge *)farmalloc(Tamanyo+32) ) == NULL ) {
|
||||
fclose(handle_sonido);
|
||||
return SIN_MEMORIA;
|
||||
}
|
||||
Wav_Mem = 1;
|
||||
pMuestra = pWav;
|
||||
|
||||
fread(pMuestra, sizeof(char), 24, handle_sonido); // C A B E C E R A . . .
|
||||
|
||||
fread(&Frec, sizeof(unsigned int), 1, handle_sonido); // C A B E C E R A . . .
|
||||
|
||||
if ( Frec <2000 ) Frec = 11025;
|
||||
|
||||
fread(pMuestra, sizeof(char), 6, handle_sonido); // C A B E C E R A . . .
|
||||
|
||||
pMuestra = pWav;
|
||||
|
||||
while( tam < (Tamanyo + 1)) {
|
||||
tam++; *pMuestra++ = getc(handle_sonido);
|
||||
//if(pWav == pMuestra) printf("\nEl puntero esta en el origen o dio la vuelta durante la carga... %ld\n", tam);
|
||||
}
|
||||
|
||||
pMuestra = pWav;
|
||||
|
||||
fclose(handle_sonido);
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ProgTimer0(unsigned Divisor)
|
||||
/* Programa el Timer 0 para que cuente desde Divisor hasta 0 */
|
||||
{
|
||||
asm CLI; /* Inhabilitamos interrupciones: secci<63>n cr<63>tica */
|
||||
outportb(0x43,0x36); /* 00111010: Timer 0, acceso secuencial y modo cont<6E>nuo */
|
||||
outportb(0x40,Divisor & 0xFF); /* Byte bajo del contador */
|
||||
outportb(0x40,Divisor >> 8); /* Byte alto del contador */
|
||||
asm STI; /* Fin de secci<63>n cr<63>tica */
|
||||
}
|
||||
|
||||
void ProgFrec(unsigned *Frecuencia)
|
||||
/* Programa el Timer 0 para que genere "Frecuencia" interrupciones por segundo */
|
||||
{
|
||||
Divisor = 1193180 / *Frecuencia;
|
||||
*Frecuencia = 1193180 / Divisor;
|
||||
ProgTimer0(Divisor);
|
||||
}
|
||||
|
||||
void interrupt Nuestra8(...)
|
||||
{
|
||||
if (!FinVoz)
|
||||
{
|
||||
(*ByteAlDAC)(*pMuestra);
|
||||
pMuestra++;
|
||||
Tamanyo--;
|
||||
if (Tamanyo<=1) FinVoz = TRUE;
|
||||
}
|
||||
outportb(0x20,0x20); /* Indicamos al controlador de interrupciones */
|
||||
} /* que la interrupci<63>n ha sido atendida */
|
||||
|
||||
void DeInitSB(void){
|
||||
|
||||
if ( Wav_Mem == 1 ) { farfree( pWav ); Wav_Mem = 0; }
|
||||
|
||||
}
|
||||
|
||||
int InitSB(void){
|
||||
|
||||
if ( Init == 0 )
|
||||
atexit( DeInitSB );
|
||||
|
||||
Init = 1;
|
||||
return ( ( SBDetect() != -1 ) ? ( SB_SPK = 1 ) : ( SB_SPK = 0 ) );
|
||||
|
||||
}
|
||||
|
||||
/**//* *//**/
|
||||
/**//* <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20> <20><><EFBFBD><EFBFBD> <20> <20> *//**/
|
||||
/**//* <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20> <20> <20> <20> <20> <20> <20><><EFBFBD><EFBFBD> <20> <20> *//**/
|
||||
/**//* <20> <20><><EFBFBD> <20> <20> <20> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20> <20><><EFBFBD> *//**/
|
||||
/**//* JD*//**/
|
||||
int PlayWav(char far *File, long Pos, long Len)
|
||||
{
|
||||
static long Old_Pos = -1;
|
||||
|
||||
if( Len == -1 ) {
|
||||
if ( strcmpi( File, Old_File ) != 0 || !Wav_Mem ) {
|
||||
if ( CargaWav(File, Pos, Len) != 1 ) { strcpy( Old_File, "\0" ); return (-1); }
|
||||
strcpy( Old_File, File );
|
||||
} else {
|
||||
|
||||
pMuestra = pWav;
|
||||
Tamanyo = T_Real;
|
||||
|
||||
}
|
||||
} else {
|
||||
if ( Old_Pos != Pos || !Wav_Mem ) {
|
||||
if ( CargaWav(File, Pos, Len) != 1 ) { strcpy( Old_File, "\0" ); return (-1); }
|
||||
Old_Pos = Pos;
|
||||
} else {
|
||||
pMuestra = pWav;
|
||||
Tamanyo = T_Real;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
switch ( SB_SPK ) {
|
||||
case 0:
|
||||
InitSpeaker();
|
||||
FinVoz = TRUE;
|
||||
ByteAlDAC = SpkSendByte;
|
||||
break;
|
||||
case 1:
|
||||
FinVoz = TRUE;
|
||||
ByteAlDAC = SBSendByte;
|
||||
break;
|
||||
case 2:
|
||||
InitDAC();
|
||||
FinVoz = TRUE;
|
||||
ByteAlDAC = LPT1DAC;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
Antigua8 = getvect(8); /* Guardamos el puntero a la antigua INT 8 */
|
||||
setvect(8,Nuestra8); /* Colocamos el puntero a nuestra rutina */
|
||||
ProgFrec(&Frec);
|
||||
FinVoz = FALSE;
|
||||
|
||||
while (!FinVoz && !Condicion_S00() );
|
||||
|
||||
// /* if ( !*/Condicion_S00() /*) while (!FinVoz)*/;
|
||||
ProgTimer0(0);
|
||||
CloseSpeaker();
|
||||
setvect(8,Antigua8);
|
||||
|
||||
return(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int PlayLongWav(char far *File, long Pos, long Len)
|
||||
{
|
||||
const int Buff = 4096;
|
||||
|
||||
FILE *handle_sonido;
|
||||
long n_lecturas, pico_lectr;
|
||||
char parte=0, key;
|
||||
|
||||
if( Wav_Mem == 1 ) { farfree( pWav ); Wav_Mem = 0; }
|
||||
|
||||
if((handle_sonido = fopen(File, "rb"))==NULL) {
|
||||
return ERROR_ABRIENDO;
|
||||
}
|
||||
|
||||
if( (Tamanyo =
|
||||
( (Len==-1) ?
|
||||
filelength(fileno(handle_sonido))-32
|
||||
:
|
||||
Len - 32
|
||||
)
|
||||
) < 1 ) { T_Real = 0; return ERROR_ABRIENDO; }
|
||||
|
||||
fseek( handle_sonido, Pos, SEEK_SET );
|
||||
|
||||
T_Real = Tamanyo;
|
||||
|
||||
n_lecturas = Tamanyo / Buff;
|
||||
pico_lectr = Tamanyo - ( n_lecturas * Buff );
|
||||
|
||||
if ( (pWav = (char huge *)farmalloc(Buff*2) ) == NULL ) {
|
||||
fclose(handle_sonido);
|
||||
return SIN_MEMORIA;
|
||||
}
|
||||
Wav_Mem = 1;
|
||||
pMuestra = pWav;
|
||||
|
||||
// fread(pMuestra, sizeof(char), 32, handle_sonido); // C A B E C E R A . . .
|
||||
fread(pMuestra, sizeof(char), 24, handle_sonido); // C A B E C E R A . . .
|
||||
|
||||
fread(&Frec, sizeof(unsigned int), 1, handle_sonido); // C A B E C E R A . . .
|
||||
|
||||
if ( Frec <2000 ) Frec = 8050;
|
||||
|
||||
fread(pMuestra, sizeof(char), 6, handle_sonido); // C A B E C E R A . . .
|
||||
|
||||
if(n_lecturas) {
|
||||
fread(pWav, sizeof(char), Buff, handle_sonido);
|
||||
Tamanyo = Buff;
|
||||
} else {
|
||||
fread(pWav, sizeof(char), pico_lectr, handle_sonido);
|
||||
Tamanyo = pico_lectr;
|
||||
}
|
||||
|
||||
|
||||
switch ( SB_SPK ) {
|
||||
case 0:
|
||||
InitSpeaker();
|
||||
FinVoz = TRUE;
|
||||
ByteAlDAC = SpkSendByte;
|
||||
break;
|
||||
case 1:
|
||||
FinVoz = TRUE;
|
||||
ByteAlDAC = SBSendByte;
|
||||
break;
|
||||
case 2:
|
||||
InitDAC();
|
||||
FinVoz = TRUE;
|
||||
ByteAlDAC = LPT1DAC;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
Antigua8 = getvect(8); /* Guardamos el puntero a la antigua INT 8 */
|
||||
setvect(8,Nuestra8); /* Colocamos el puntero a nuestra rutina */
|
||||
ProgFrec(&Frec);
|
||||
FinVoz = FALSE;
|
||||
|
||||
parte = 1;
|
||||
|
||||
|
||||
|
||||
if ( n_lecturas > 0 ) {
|
||||
|
||||
while( n_lecturas > 0 ){ // Ejecutamos tantas veces con Lecturas Buff se
|
||||
// puedan hacer...
|
||||
|
||||
n_lecturas--; // Vaya se nos fue una lectura...
|
||||
|
||||
if ( n_lecturas > 0 ) { // Si quedan lecturas... llenamos el Doble Buffer
|
||||
|
||||
if( parte ) fread( (pWav+4096), sizeof(char), Buff, handle_sonido );
|
||||
else fread( (pWav ), sizeof(char), Buff, handle_sonido );
|
||||
|
||||
} else
|
||||
if ( pico_lectr > 0) {
|
||||
if( parte ) fread( (pWav+4096), sizeof(char), pico_lectr, handle_sonido );
|
||||
else fread( (pWav ), sizeof(char), pico_lectr, handle_sonido );
|
||||
}
|
||||
|
||||
|
||||
while (!FinVoz && !(key = Condicion_S00() ) );
|
||||
// if ( !(key = Condicion()) ) while (!FinVoz);
|
||||
if ( key ) { FinVoz = TRUE; break; }
|
||||
|
||||
|
||||
if ( (n_lecturas > 0 || pico_lectr !=0) && !key ) {
|
||||
if( parte ){ parte = 0; /* Ya colocado */}
|
||||
else { parte = 1; pMuestra = pWav; }
|
||||
|
||||
if (n_lecturas > 0) Tamanyo = Buff; else Tamanyo = pico_lectr;
|
||||
FinVoz = FALSE;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
while (!FinVoz && !Condicion_S00());
|
||||
// if ( !(Condicion()) ) while (!FinVoz);
|
||||
} else
|
||||
while (!FinVoz && !Condicion_S00());
|
||||
// if ( !(Condicion()) ) while (!FinVoz);
|
||||
|
||||
ProgTimer0(0);
|
||||
CloseSpeaker();
|
||||
setvect(8,Antigua8);
|
||||
|
||||
fclose(handle_sonido);
|
||||
DeInitSB();
|
||||
return(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// int far TeclaPulsada(void)
|
||||
/* Esta funci<63>n mira si se ha pulsado una tecla pero SIN llamadas a la BIOS,
|
||||
de forma que no se inhabilitan las interrupciones en cada llamada, cosa
|
||||
que bajar<61>a mucho la calidad de reproducci<63>n con el altavoz interno. */
|
||||
// {
|
||||
// return ( *(unsigned *) MK_FP(0x40,0x1A) != *(unsigned *) MK_FP(0x40,0x1C) );
|
||||
// }
|
||||
|
||||
int Condicion_S00(void)
|
||||
{
|
||||
|
||||
union REGS RaT;
|
||||
RaT.x.ax = 3;
|
||||
int86(0x33, &RaT, &RaT);
|
||||
|
||||
return (( *(unsigned *) MK_FP(0x40,0x1A) != *(unsigned *) MK_FP(0x40,0x1C) ) || (RaT.x.bx & 1));
|
||||
|
||||
}
|
BIN
WAVPLAV/VOCPLAY.OBJ
Normal file
BIN
WAVPLAV/VOCPLAY.OBJ
Normal file
Binary file not shown.
75
WAVPLAV/WAVPLAY.H
Normal file
75
WAVPLAV/WAVPLAY.H
Normal file
@ -0,0 +1,75 @@
|
||||
|
||||
|
||||
|
||||
//******************************************/
|
||||
//**/ /**/
|
||||
//**/ Funcion encargada de inicializar /**/
|
||||
//**/ la Sb, Speaker, o DAC... /**/
|
||||
//******************************************/
|
||||
extern int InitSB(void);
|
||||
|
||||
//******************************************/
|
||||
//**/ /**/
|
||||
//**/ Funcion encargada de desconectar /**/
|
||||
//**/ la Sb, Speaker, o DAC... /**/
|
||||
//******************************************/
|
||||
extern void DeInitSB(void);
|
||||
|
||||
|
||||
//****************************************** ;El fichero Wav debe estar grabado
|
||||
///**/ Carga y Toca un fichero WAV o Wav' /** ;a 8050 Hz.
|
||||
///**/ Se le pasan el Nombre del Fichero /**
|
||||
///**/ y un puntero a la funcion que /** ;Devuelve un 0 si todo ha ido
|
||||
///**/ determinara cuando se interrumpira /** ;bien...
|
||||
///**/ el sonido antes del final del mismo/**
|
||||
///******************************************
|
||||
///////////////////////////////////////////
|
||||
extern int PlayWav(char *File, long Pos, long Len);
|
||||
|
||||
/******************************************/
|
||||
//**/ Igual que PlayWav... /**/
|
||||
///**/ /**/
|
||||
///**/ Solo que sirve para reproducir /**/
|
||||
///**/ ficheros WAV de 300.000 Mb de /**/
|
||||
///**/ Tamanyo utilizando solo un doble /**/
|
||||
///**/ buffer de 8K /**/
|
||||
///**/ /**/
|
||||
///******************************************/
|
||||
///////////////////////////////////////////
|
||||
extern int PlayLongWav(char *File, long Pos, long Len);
|
||||
|
||||
/******************************************/
|
||||
//**/ Mira si se ha pulsado una tecla /**/
|
||||
///**/ pero sin utilizar la BIOS ni /**/
|
||||
///**/ interruppir las interrupciones /**/
|
||||
///******************************************/
|
||||
///////////////////////////////////////////
|
||||
extern int far TeclaPulsada(void);
|
||||
|
||||
/// SB_SPK :: Aunque esta variable se carga sola cuando se inicializa
|
||||
/// la SB, se puede forzar a cargarla manualmente...
|
||||
///
|
||||
/// V A L O R Salida del sonido digitalizado
|
||||
///
|
||||
/// 0 Speaker
|
||||
/// 1 Sound Blaster
|
||||
/// 2 Dac Casero...
|
||||
extern char SB_SPK;
|
||||
|
||||
/// WARNING !!!!!
|
||||
///
|
||||
/// Las variables a continuaci<63>n enseladas no deben se modificadas y si
|
||||
/// estan hay es solo para que puedas, si lo deseas, realizar un seguimiento
|
||||
/// de los datos que estan sonando...
|
||||
|
||||
extern char huge *pMuestra; /* Puntero a la muestra que suena */
|
||||
extern long Tamanyo, /* Tama<6D>o de los datos que estan sonando */
|
||||
T_Real; /* Tama<6D>o real de los datos */
|
||||
|
||||
// Nota:
|
||||
|
||||
// Con PlayLongWav como es natural no se puede cargar un WAV de 300.000 Mb
|
||||
// en memoria por lo que Tamanyo != T_Real e indica el tama<6D>o de la muestra
|
||||
// que queda por reproducir, en bytes.
|
||||
//
|
||||
|
BIN
WAVPLAV/WAVPLAYC.LIB
Normal file
BIN
WAVPLAV/WAVPLAYC.LIB
Normal file
Binary file not shown.
Reference in New Issue
Block a user