Das deutsche QBasic- und FreeBASIC-Forum Foren-Übersicht Das deutsche QBasic- und FreeBASIC-Forum
Für euch erreichbar unter qb-forum.de, fb-forum.de und freebasic-forum.de!
 
FAQFAQ   SuchenSuchen   MitgliederlisteMitgliederliste   BenutzergruppenBenutzergruppen  RegistrierenRegistrieren
ProfilProfil   Einloggen, um private Nachrichten zu lesenEinloggen, um private Nachrichten zu lesen   LoginLogin
Zur Begleitseite des Forums / Chat / Impressum
Aktueller Forenpartner:

Soundkarte ansteuern

 
Neues Thema eröffnen   Neue Antwort erstellen    Das deutsche QBasic- und FreeBASIC-Forum Foren-Übersicht -> Allgemeine Fragen zu FreeBASIC.
Vorheriges Thema anzeigen :: Nächstes Thema anzeigen  
Autor Nachricht
MatthiasGP



Anmeldungsdatum: 13.11.2009
Beiträge: 4
Wohnort: Korschenbroich

BeitragVerfasst am: 13.11.2009, 00:41    Titel: Soundkarte ansteuern Antworten mit Zitat

Hallo, Allerseits,
seit heute beschäftige ich mich wieder mit BASIC. Auf der Suche nach einem aktuellen Compiler stieß ich auf FreeBasic. Sehr schön. elegant.
Leider meine Kenntnisse nicht mehr. (Ist auch schon ein Weilchen her)
Da ich kürzlich ein VF-Display erworben hatte, um es gegen das defekte eines HP designjet auszutauschen und das leider nicht hingehauen hat, hab ich begonnen, das Teil über die RS232 anzusprechen. Klappt eigentlich ganz gut. (auch mit dem USB2seriell-Adapter) Nun ja und nun wollte ich ein simples VU-Meter damit basteln, also die Signale der Soundcard auslesen (keine soundblaster sondern eine onboard Realtek) und dazu fehlt mir leider die Routine bzw. ich finde die entspr. Befehle nicht. (bass.dll ??)
Jetzt meine Frage: wie bekomme ich die Signale der Karte in Freebasic ausgelesen, um sie für die horizontale Balkengrafik zu nutzen (einfach als Block-Diagramm) Das display hat 2x20 Chracters.
Die "Uhr" war ziemlich simpel:
Open "COM2:9600,N,8,1,CD0,CS0,DS0" FOR RANDOM AS #1
Print #1," " 'cls funktioniert nicht
Locate 1, 1: PRINT " (Programmende mit q)"
Do
Dim h As String = Time
IF h = Time then Print #1, " " + Time + " "
LOOP UNTIL INKEY = "q"
Close #1
herzliche Grüße und Danke für die Antwortmühe
Matthias
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden Website dieses Benutzers besuchen
Jojo
alter Rang


Anmeldungsdatum: 12.02.2005
Beiträge: 9736
Wohnort: Neben der Festplatte

BeitragVerfasst am: 13.11.2009, 08:27    Titel: Antworten mit Zitat

Dafür gibt's viele Bibliotheken, z.B. die BASS-Bibliothek, der schon Beispiele zur Tonaufnahme für VisualBasic beiliegen (lässt sich ganz einfach übersetzen). Ansonsten wurde die Frage schon mehrmals im Forum gestellt, einfach mal die Forensuche benutzen.
_________________
» Die Mathematik wurde geschaffen, um Probleme zu lösen, die es nicht gäbe, wenn die Mathematik nicht erschaffen worden wäre.
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden Website dieses Benutzers besuchen
MatthiasGP



Anmeldungsdatum: 13.11.2009
Beiträge: 4
Wohnort: Korschenbroich

BeitragVerfasst am: 13.11.2009, 09:10    Titel: Antworten mit Zitat

Hallo, Jojo, guten Morgen
und Danke für die Antwort. Ich hab die beiden Programme von Volta gefunden (Oszilloskop und Frequenz) Leider quittieren sie immer mit mp3 Datei kann nicht gestartet werden... (evtl. falsches Format ?) die soundcard spielt das file allerdings. Die Datei liegt auch im Verzeichnis, wo das Programm kompiliert wurde...
ich komm irgendwie nicht weiter...Schade (freebasic läuft unter WIN7)
Grüße
matthias
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden Website dieses Benutzers besuchen
volta



Anmeldungsdatum: 04.05.2005
Beiträge: 1876
Wohnort: D59192

BeitragVerfasst am: 13.11.2009, 15:05    Titel: Antworten mit Zitat

Also,
ich habe alles noch mal nachgeprüft und es läuft!
Hier sind alle notwendigen Dateien (bas, dll, bi, a), mit einer mp3 zum testen und kompilierten Beispielen:
http://volta.de.tt/zips/bass_spielerei.zip (220k)
_________________
Warnung an Choleriker:
Dieser Beitrag kann Spuren von Ironie & Sarkasmus enthalten.
Zu Risiken & Nebenwirkungen fragen Sie Ihren Therapeuten oder Psychiater.
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden Website dieses Benutzers besuchen
MatthiasGP



Anmeldungsdatum: 13.11.2009
Beiträge: 4
Wohnort: Korschenbroich

BeitragVerfasst am: 13.11.2009, 21:29    Titel: Antworten mit Zitat

Hallo, Volta,
SUPER, Danke, ja läuft... mir fehlte wohl die bass.bi Datei (shame on me)
Ist genau ,w as ich gesucht hab. Nochmals Danke.
Ich glaube ich werde Freebasic Fan.
Matthias
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden Website dieses Benutzers besuchen
Jojo
alter Rang


Anmeldungsdatum: 12.02.2005
Beiträge: 9736
Wohnort: Neben der Festplatte

BeitragVerfasst am: 13.11.2009, 22:36    Titel: Antworten mit Zitat

Die bass.bi liegt bei FB dabei, aber in einer hoffnungslos veralteten Version.
_________________
» Die Mathematik wurde geschaffen, um Probleme zu lösen, die es nicht gäbe, wenn die Mathematik nicht erschaffen worden wäre.
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden Website dieses Benutzers besuchen
MatthiasGP



Anmeldungsdatum: 13.11.2009
Beiträge: 4
Wohnort: Korschenbroich

BeitragVerfasst am: 14.11.2009, 00:26    Titel: Antworten mit Zitat

Hallo, Volta...
Jou, war dann ganz simpel:
OPEN "COM2:9600,N,8,1,CD0,CS0,OP0" FOR RANDOM AS #1 (am Beginn)
Print #1, String$ (40, " ") 'Pseudo CLS
Dim h As Integer = (HiWord(peak) Shr cool/5 '20 digits
Dim l As Integer = (LoWord(peak) Shr cool/5
Print #1, String$(h, Chr$(219))
Print #1, String$(l, Chr$(219))
close #1 (am Ende)

sieht auch ganz niedlich aus...
kann man die soundcard auch "direkt" abgreifen, also ohne ein mp3 file zu deklarieren ?

Matthias
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden Website dieses Benutzers besuchen
volta



Anmeldungsdatum: 04.05.2005
Beiträge: 1876
Wohnort: D59192

BeitragVerfasst am: 14.11.2009, 00:59    Titel: Antworten mit Zitat

Zitat:
kann man die soundcard auch "direkt" abgreifen ..
ist mir bisher nicht gelungen.
Nur wenn ich selbst Töne auf der Soundkarte ausgebe ist mir bekannt wo die Daten dafür sind und welche Treiber benutzt werden.
In alten DOS-Zeiten konnte man noch Hardwareports abfragen, is ja kaum mehr möglich missbilligen
_________________
Warnung an Choleriker:
Dieser Beitrag kann Spuren von Ironie & Sarkasmus enthalten.
Zu Risiken & Nebenwirkungen fragen Sie Ihren Therapeuten oder Psychiater.
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden Website dieses Benutzers besuchen
chutullu



Anmeldungsdatum: 18.10.2005
Beiträge: 77

BeitragVerfasst am: 22.11.2009, 13:42    Titel: Antworten mit Zitat

@volta
@MatthiasGP


Habe mich mal damit versucht, wie gesagt versucht, bin mit Soundsynthese nie zurecht gekommen ...

Aber hier ein paar Infos zur Ansteuerung SB16 mit DSP :

Zitat:

ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
º Programming the SoundBlaster 16 DSP º
º Written by Ethan Brodsky º
º (ericbrodsky@psl.wisc.edu) º
º Version 3.1 º
º 2/10/95 º
ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

ÚÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
³ Disclaimer ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÙ

This information is distributed AS IS. The author specifically disclaims
responsibility for any loss of profit or any consequential, incidental,
or other damages resulting from the use or misuse of this information.
This information may be freely distributed in any form as long as this
disclaimer remains intact.

ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
³ Introduction ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

The Sound Blaster 16 is capable of both FM and digitized sounds. Digitized
sound capibilities range from 8-bit mono 5000 HZ sound all the way up to
16-bit stereo sound at 44khz. This FAQ documents programming the SB16 DSP
CT1341 chip for recording and playback of digitized audio. Prior knowledge
on programming earlier Sound Blaster sound cards is necessary.

ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
³ The Sound Blaster 16 DSP I/O Ports ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

The SB16's DSP chip is programming using several I/O ports at a base I/O
address determined by jumper settings. On the SB16, there are 16 I/O ports
which are used for FM synthesized music, mixer settings, DSP programming and
CD-ROM access. Five of these ports are used in programming the DSP. They
are listed below.

2x6h - DSP Reset
2xAh - DSP Read
2xCh - DSP Write (Command/Data), DSP write-buffer status (Bit 7)
2xEh - DSP Read-buffer status (Bit 7), DSP interrupt acknowledge
2xFh - DSP 16-bit interrupt acknowledge

ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
³ Resetting the DSP ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

You have to reset the DSP before you can program it. The DSP can be reset
using the following procedure:
1) Write a 1 to the reset port (2x6)
2) Wait for 3 microseconds
3) Write a 0 to the reset port (2x6)
4) Poll the read-buffer status port (2xE) until bit 7 is set
5) Poll the read data port (2xA) until you receive an AA

The DSP usually takes about 100 microseconds to initialized itself. After
this period of time, if the return value is not AA or there is no data at
all, then the SB card may not be installed or an incorrect I/O address is
being used.

ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
³ Writing to the DSP ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

To write a byte to the SB16, the following procedure should be used:
1) Read the write-buffer status port (2xC) until bit 7 is cleared
2) Write the value to the write port (2xC)

ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
³ Reading the DSP ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

To read a byte from the SB16, the following procedure should be used:
1) Read the read-buffer status port (2xE) until bit 7 is set
2) Read the value from the read port (2xA)

ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
³ Programming the DMA Controller ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

The DMA (Direct Memory Access) controller controls data transfers between
I/O devices and memory without using the CPU. An Intel 8237 DMAC integrated
circut is used to control this. An IBM compatible computer has two DMA
controllers, one for 8-bit transfers and one for 16-bit transfers. The DMA
controller, coupled with an external page register, is capable of transfering
blocks of up 64k to the SB16. Here is information on I/O ports and register
settings necessary for sound card I/O:

I/O port addresses for the DMA Address and Count Registers
ÉÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
º Controller ³ I/O address ³ Function º
ÌÍÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º DMA 1 ³ 00 ³ Channel 0 address º
º 8-bit ³ 01 ³ Channel 0 count º
º Slave ³ 02 ³ Channel 1 address º
º ³ 03 ³ Channel 1 count º
º ³ 04 ³ Channel 2 address º
º ³ 05 ³ Channel 2 count º
º ³ 06 ³ Channel 3 address º
º ³ 07 ³ Channel 3 count º
ÌÍÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º DMA 2 ³ C0 ³ Channel 4 address º
º 16-bit ³ C2 ³ Channel 4 count º
º Master ³ C4 ³ Channel 5 address º
º ³ C6 ³ Channel 5 count º
º ³ C8 ³ Channel 6 address º
º ³ CA ³ Channel 6 count º
º ³ CC ³ Channel 7 address º
º ³ CE ³ Channel 7 count º
ÈÍÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

I/O port addresses for the control registers
ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
º Address ³ Operation ³ Function º
º DMAC1 DMAC2 ³ ³ º
ÌÍÍÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º 0A D4 ³ Write ³ Write single mask register º
º 0B D6 ³ Write ³ Write mode register º
º 0C D8 ³ Write ³ Clear byte pointer flip-flop º
ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

I/O port addresses for lower page registers
ÉÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
º Address ³ Function º
ÌÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º 81 ³ 8-bit DMA channel 2 page º
º 82 ³ 8-bit DMA channel 3 page º
º 83 ³ 8-bit DMA channel 1 page º
º 87 ³ 8-bit DMA channel 0 page º
º 89 ³ 16-bit DMA channel 6 page º
º 8A ³ 16-bit DMA channel 7 page º
º 8B ³ 16-bit DMA channel 5 page º
ÈÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

Mode register bit assignments
ÉÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
º Bit/Value ³ Function º
ÌÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º Bits 7:6 ³ Mode selection bits º
º 00 ³ Demand mode selected º
º 01 ³ Single mode selected º
º 10 ³ Block mode selected º
º 11 ³ Cascade mode selected º
ÌÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º Bit 5 ³ Address increment/decrement bit º
º 1 ³ Address decrement selected º
º 0 ³ Address increment selected º
ÌÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º Bit 4 ³ Auto-initialization enable bit º
º 1 ³ Auto-initialized DMA selected º
º 0 ³ Single-cycle DMA selected º
ÌÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º Bits 3:2 ³ Transfer bits º
º 00 ³ Verify transfer º
º 01 ³ Write transfer (To memory) º
º 10 ³ Read transfer (From memory) º
º 11 ³ Illegal º
º ** ³ Ignored if bits 7:6 = 11 º
ÌÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º Bits 1:0 ³ Channel selection bits º
º 00 ³ Select channel 0 (4) º
º 01 ³ Select channel 1 (5) º
º 10 ³ Select channel 2 (6) º
º 11 ³ Select channel 3 (7) º
ÈÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

Write single mask bit assignments
ÉÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
º Bit/Value ³ Function º
ÌÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º Bits 7:3 ³ Unused (Set to 0) º
ÌÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º Bit 2 ³ Set/clear mask bit º
º 1 ³ Set mask bit (Disable channel) º
º 0 ³ Clear mask bit (Enable channel) º
ÌÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º Bits 1:0 ³ Channel selection bits º
º 00 ³ Select channel 0 (4) º
º 01 ³ Select channel 1 (5) º
º 10 ³ Select channel 2 (6) º
º 11 ³ Select channel 3 (7) º
ÈÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

DMAC2 is used for 16-bit I/O and DMAC1 is used for 8-bit I/O. The procedure
for starting a transfer is complicated, so I'll list the steps for starting
the type of DMA transfers used for sound I/O:

1) Calculate the absolute linear address of your buffer
LinearAddr := Seg(Ptr^)*16 + Ofs(Ptr^));

2) Disable the sound card DMA channel by setting the appropriate mask bit
Port[MaskPort] := 1 + (Channel mod 4);

3) Clear the byte pointer flip-flop
Port[ClrBytePtr] := AnyValue;

4) Write the DMA mode for the transfer
The mode selection bits should be set to 00 for demand mode. The
address inc/dec bit should be set to 0 for address increment. The
auto-initialization bit should be set appropriately. I will discuss
auto-initialized DMA later. The transfer bits should be set to 10
for playback and 01 for recording. The channel select should be
set to the sound card DMA channel. Be aware that "read" means a read
from memory (Write to sound card) and that "write" means a write to
system memory (Read from sound card)
Port[ModePort] := Mode + (Channel mod 4);
Some often used modes are:
48h+Channel - Single-cycle playback
58h+Channel - Auto-initialized playback
44h+Channel - Single-cycle recording
54h+Channel - Auto-initialized recording

5) Write the offset of the buffer, low byte followed by high byte. For
sixteen bit data, the offset should be in words from the start of a
128kbyte page. The easiest method for computing 16-bit parameters is
to divide the linear address by two before calculating offset.
if SixteenBit
then
begin
BufOffset := (LinearAddr div 2) mod 65536;
Port[BaseAddrPort] := Lo(BufOffset);
Port[BaseAddrPort] := Hi(BufOffset);
end
else
begin
BufOffset := LinearAddr mod 65536;
Port[BaseAddrPort] := Lo(BufOffset);
Port[BaseAddrPort] := Hi(BufOffset);
end;

6) Write the transfer length, low byte followed by high byte. For an
8-bit transfer, write the number of bytes-1. For a 16-bit transfer,
write the number of words-1.
Port[CountPort] := Lo(TransferLength-1);
Port[CountPort] := Hi(TransferLength-1);

7) Write the buffer page to the DMA page register.
Port[PagePort] := LinearAddr div 65536;

cool Enable the sound card DMA channel by clearing the appropriate mask bit
Port[MaskPort] := DMAChannel mod 4;

ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
³ Setting the sampling rate ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

Unlike earlier Sound Blasters, the SB16 is programmed with actual sampling
rates instead of time constants. On the SB16, the sampling rate is set
using DSP commands 41h and 42h. Command 41h is used for output and 42h is
used for input. I have heard that on the SB16, both these command currently
do the same thing, but I would recommend using the individual commands to
guarantee compatibility with future sound cards. The procedure for setting
the sampling rate is:
1) Write the command (41h for output rate, 42h for input rate)
2) Write the high byte of the sampling rate (56h for 22050 hz)
3) Write the low byte of the sampling rate (22h for 22050 hz)

ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
³ Digitized sound I/O ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

To record or play back sound, you should use the following sequence:

1) Allocate a buffer that does not cross a 64k physical page boundary
2) Install an interrupt service routine
3) Program the DMA controller for background transfer
4) Set the sampling rate
5) Write the I/O command to the DSP
6) Write the I/O transfer mode to the DSP
7) Write the block size to the DSP (Low byte/High byte)

Upon interrupt when using single-cycle DMA:
1) Program DMA controller for next block
2) Program DSP for next block
3) Copy next block if double-buffering
4) Acknowledge the interrupt with the SB by reading from port 2xE for
8-bit sound or port 2xF for 16-bit sound.
5) Acknowledge the end of interrupt with the PIC by writing 20h to port
20h. If the sound card is on IRQ8-15, you must also write 20h to A0h.

ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
³ DSP commands ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

D0 - Pause 8-bit DMA mode digitized sound I/O initiated by command Cxh.
Applicable to both single-cycle and auto-initialized DMA I/O.
D4 - Continue 8-bit DMA mode digitized sound I/O paused using command D0.
Applicable to both single-cycle and auto-initialzied DMA I/O.

D5 - Pause 16-bit DMA mode digitized sound I/O initiated by command Bxh.
Applicable to both single-cycle and auto-initialized DMA I/O.
D6 - Continue 16-bit DMA mode digitized sound I/O paused using command D5
Applicable to both single-cycle and auto-initialized DMA I/O.

D9 - Exit 16-bit auto-initialized DMA mode digitized sound I/O after the
end of the current block.
DA - Exit 8-bit auto-initialized DMA mode digitized sound I/O after the
end of the current block.

E1 - Get DSP version number. After sending this command, read back two
bytes form the DSP. The first byte is the major version number and
the second byte is the minor version number. A SB16 should have a
DSP version of 4.00 or greater. Check this before using an SB16
specific commands.

Bx - Program 16-bit DMA mode digitized sound I/O
Command sequence: Command, Mode, Lo(Length-1), Hi(Length-1)
Command:
ÉÍÍÍÍÑÍÍÍÍÑÍÍÍÍÑÍÍÍÍÑÍÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍÍÑÍÍÍÍ»
º D7 ³ D6 ³ D5 ³ D4 ³ D3 ³ D2 ³ D1 ³ D0 º
ÌÍÍÍÍØÍÍÍÍØÍÍÍÍØÍÍÍÍØÍÍÍÍÍÍÍØÍÍÍÍÍÍØÍÍÍÍÍÍÍØÍÍÍ͹
º 1 ³ 0 ³ 1 ³ 1 ³ A/D ³ A/I ³ FIFO ³ 0 º
ÈÍÍÍÍÏÍÍÍÍÏÍÍÍÍÏÍÍÍÍÅÄÄÄÄÄÄÄÅÄÄÄÄÄÄÅÄÄÄÄÄÄÄÅÍÍÍͼ
³ 0grinsen/A ³ 0=SC ³ 0=off ³
³ 1=A/D ³ 1=AI ³ 1=on ³
ÀÄÄÄÄÄÄÄÁÄÄÄÄÄÄÁÄÄÄÄÄÄÄÙ
Common commands:
B8 - 16-bit single-cycle input
B0 - 16-bit single-cycle output
BE - 16-bit auto-initialized input
B6 - 16-bit auto-initialized output

Mode:
ÉÍÍÍÍÑÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÑÍÍÍÍÑÍÍÍÍÑÍÍÍÍ»
º D7 ³ D6 ³ D5 ³ D4 ³ D3 ³ D2 ³ D1 ³ D0 º
ÌÍÍÍÍØÍÍÍÍØÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍØÍÍÍÍØÍÍÍÍØÍÍÍ͹
º 0 ³ 0 ³ Stereo ³ Signed ³ 0 ³ 0 ³ 0 ³ 0 º
ÈÍÍÍÍÏÍÍÍÍÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÅÍÍÍÍÏÍÍÍÍÏÍÍÍÍÏÍÍÍͼ
³ 0=Mono ³ 0=unsigned ³
³ 1=Stereo ³ 1=signed ³
ÀÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÙ

Cx - Program 8-bit DMA mode digitized sound I/O
Same procedure as 16-bit sound I/O using command Bx
Common commands:
C8 - 8-bit single-cycle input
C0 - 8-bit single-cycle output
CE - 8-bit auto-initialized input
C6 - 8-bit auto-initialized output

The FIFO is used to eliminate inconsistencies in the sample period
when the sound card is not able to get DMA when it needs it. With
FIFO disabled, the card attempts DMA at precisely the instant that
it needs a sample. If another device with a higher priority is
accessing DMA, the sound card waits for the sample and the sampling
rate may be decreased. The FIFO allows the DMA sample period to be
more erratic without affecting the audio quality. The FIFO is cleared
whenever a command is sent to the DSP. In Single-cycle mode, the DSP
is constantly being reprogrammed. The FIFO may still contain data which
has not been output when it cleared. To avoid this problem, the FIFO
should be turned off for single-cycle mode. When in auto-initialized
mode, the DSP is never reprogrammed. The FIFO can be left on and sound
quality will be improved.

ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
³ Auto-initialized DMA ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

When single-cycle DMA is used, sound output stops at the end of each block.
The interrupt handler can start another transfer, but there will be a break
in output. This causes a click between each block, reducing sound quality.
When auto-initialized DMA is used, sound output loops around at the end of
the buffer. The DMA controller keeps transfering the same block of memory
that the DMA transfer was initiated with. When the end of the buffer is
reached, it will start sending the buffer again by auto-initializing the
current offset and count registers with the values stored in the base offset
and count registers. The usual method for achieving click-less output is to
allocate a buffer and divide it into two blocks. Program the DMA controller
with the length of the whole buffer, but program the SB16 with the length of
a block. (Half of the buffer) An interrupt occurs for each sound card block,
so two interrupts will occur each time the buffer is played, once at the
midpoint (Start of the second block) and once at the end (In effect, the
start of the first block) The interrupt handler should copy data into the
block that was just finished so that the data is ready when it is needed for
output. The programming procedure for an auto-initialized DMA transfer is
identical to the procedure for a single-cycle DMA transfer, except that bit
4 of the DMA mode register and bit 3 of the DSP command are set.

Upon interrupt when using auto-initialized DMA:
1) Copy next chunk into output buffer block that just finished
2) Acknowledge the interrupt with the SB by reading from port 2xE for
8-bit sound or port 2xF for 16-bit sound.
3) Acknowledge the end of interrupt with the PIC by writing 20h to port
20h. If the sound card is on IRQ8-15, you must also write 20h to A0h.

To stop sound immediately:
8-bit - Write DSP command D0h (Pause 8-bit DMA mode digitized sound I/O)
16-bit - Write DSP command D5h (Pause 16-bit DMA mode digitized sound I/O)
(Stops sound immediately, without an interrupt)

To stop the sound at the end of the currently block:
8-bit - Write DSP command DAh (Stop 8-bit auto-init DMA sound I/O)
16-bit - Write DSP command D9h (Stop 16-bit auto-init DMA sound I/O)
(These two commands will stop the sound at the end of the current
block. If your program is not prepared for an interrupt after output
is finished, it may cause problems)

You can also end auto-initialized mode by reprogramming the DSP for
single-cycle mode. The card then switches from A/I mode to S/C mode after
the next interrupt. It will then contiue to play or record for the length
specified, generate an interrupt and stop. This will allow you to stop
output exactly at the end of the data, without requiring the remainder of
the DMA buffer to be filled with silence. This technique may or may not
be useful to you. I would recommend using the pause commands documented
in in the immediate stop section unless another method is more suited to
your purpose.

ÚÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
³ References ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÙ

Title: Developer Kit for the Sound Blaster Series, Second Edition.
Publishers: Creative Technology Ltd.

Title: Intel 486 Microcomputer Model 401 Board Technical Ref. Manual
Publisher: Intel Corporation
Order-number: 504366-002

Title: 8237A High Performance Programmable DMA Controller specs
Publisher: Intel Corporation
Order-number: 231466-005

Title: 8259A Programmable Interrupt Controller specs
Publisher: Intel Corporation
Order-number: 231468-003

Title: SMIX Sound System
Author: Ethan Brodsky
Location: x2ftp.oulu.fi /pub/msdos/programming/mxlibs/smix*.zip
(May be moved to another directory)

Thanks to Douglas Kaden at Creative Labs for information on 16-bit DMA,
FIFO mode, and numerous other topics.
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
Jojo
alter Rang


Anmeldungsdatum: 12.02.2005
Beiträge: 9736
Wohnort: Neben der Festplatte

BeitragVerfasst am: 22.11.2009, 14:21    Titel: Antworten mit Zitat

Du willst doch nicht wirklich aus FB heraus einen SB16 hardwarenah ansteuern, oder?
_________________
» Die Mathematik wurde geschaffen, um Probleme zu lösen, die es nicht gäbe, wenn die Mathematik nicht erschaffen worden wäre.
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden Website dieses Benutzers besuchen
Beiträge der letzten Zeit anzeigen:   
Neues Thema eröffnen   Neue Antwort erstellen    Das deutsche QBasic- und FreeBASIC-Forum Foren-Übersicht -> Allgemeine Fragen zu FreeBASIC. Alle Zeiten sind GMT + 1 Stunde
Seite 1 von 1

 
Gehe zu:  
Du kannst keine Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum nicht antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.

 Impressum :: Datenschutz