Output of digitized sound - how to output sound to AY and PR0FI C0V0X.

Hacker #07
 Output digitized audio.                          .BIG BRAIN 
                                                                
                                                                
ZX-SPECTRUM in Russia has several devices for audio output.
This is a good old beeper, coprocessor AU-3-8910/12, whole
the C0V0X family (LPT-СOV0X, PROFI C0V0X, SOUND DRIVE, ...), and
newly developed GENERAL SOUND sound card.             
                                                                
I'll tell you how to output sound to AU and PROFI C0V0Х. Output to
C0V0Х's are not very different from each other, but GENERAL SOUND's
didn't see or hear at all.                                    
                                                                
Let's look at common 8-bit instruments from PC
Sceream Tracker:                                               
                                                                
The easiest way is to output them to C0V0X:                               
                                                                
        LD A,#80 ; installation KP58OBB55A               
        0UT (127),A                                         
                                                                
        LD HL, tool start                           
        LDDE,tool length                            
                                                                
L1 LD А,(HL)                                          
                                                                
        LD B, delay                                      
        DJNZ$                                               
                                                                
        0UT (#3F),A ; #5F - second channel                   
                                                                
        INC HL                                              
        DEC DE                                              
        LD A,D                                             
        0R E                                               
        JP NZ,L1                                           
                                                                
AU allows you to output only 4 bits of sound, which somewhat reduces
quality:                                                       
                                                                
        LD BC,#FFFD ; installation AU-3-8910/12             
        LD A,7                                             
        0UT (C),A                                           
        LD Sun,#BFFDLD А,#FF ; sound and noise output                   
 0UT (C),A                                           
        LD Sun,#FFFD                                        
        LD A,8; Channels: 8 - A, 9 - B, 10 - C        
        0UT (C),A                                           
                                                                
        LD HL, tool start                           
        LD DE,tool length                            
                                                                
        LD Sun,#BFFD                                        
                                                                
L1 LD А,(HL)                                          
                                                                
        EXX                                                     
        LD B, delay                                      
        DJNZ$                                               
        EXX                                                     
                                                                
        RRA ; highlighting the 4 most significant bits                     
        RRA                                                     
        RRARRA                                                     
        0UT (C),A                                           
                                                                
        INC HL                                              
        DEC DE                                              
        LD A,D                                             
        0R E                                               
        JP NZ,L1                                           
                                                                
Using the method described above, you can also play WAV files from a PC.  
On C0V0X you can get very high quality sounds.             
                                                                
There are also 1-bit digitizations that can be obtained from
using programs: Instrument Editor 1.01 and Instrument Editor
2.01.  Sound is recorded into memory from the tape recorder port one at a time
bat.  The quality is noticeably worse than when playing 8-bit
digitization.                                                      
                                                                
The highest quality sound can be obtained on a beeper:           
                                                                
        LD HL, tool startLD DE,tool length                            
                                                                
L1                                                              
 LD A,(HL)                                          
        LD С,%00010000; mask                             
                                                                
        LD B, delay                                      
        DJNZ$                                               
                                                                
        R.L.A.                                                     
        LD V,A                                             
        SBC A,A                                             
        AND C                                               
        0UT (#FE),A                                         
                                                                
        LD A,B ┐                                       
        RLA │                                       
        LD B, A │ repeat 7 times                       
        SBC A,A │                                       
        AND C │                                       
        0UT (#FE),A ┘INC HL                                              
        DEC DE                                              
        LD A,D                                             
 0R E                                               
        JP NZ,L1                                           
                                                                
                                                                
PROFI C0V0X :                                                   
                                                                
        LD A,#80 ; installation KP58OBB55A                
        0UT (127),A                                         
                                                                
        LD HL, tool start                           
        LD DE,tool length                            
                                                                
L1                                                              
        LD A,(HL)                                          
                                                                
        LD B, delay                                      
        DJNZ$R.L.A.                                                     
        LD V,A                                             
        SBC A,A                                             
        0UT (#3F),A ; #5F - another channel                    
                                                                
        LD A,B ┐                                       
        RLA │                                       
        LD B, A │ repeat 7 times                       
        SBC A,A │                                       
        0UT (#3F),A ┘                                       
                                                                
        INC HL                                              
        DEC DE                                              
        LD A,D                                             
        0R E                                               
        JP NZ,L1                                           
                                                                
AU-3-8910/12:                                                  
                                                                
        LD BC,#FFFD ; installation AU-3-8910/12LD A,7                                             
        0UT (C),A                                           
        LD Sun,#BFFD                                        
        LD А,#FF ; sound and noise output                   
        0UT (C),A                                           
        LD Sun,#FFFD                                        
 LD A,8 ; Channels: 8 - A, 9 - B, 10 - C        
        0UT (C),A                                           
                                                                
        LD HL, tool start                           
        LD DE,tool length                            
        LD Sun,#BFFD                                        
                                                                
L1 PUSH DE                                              
        LD A,(HL)                                          
        LD D,%00001111 ; mask                             
                                                                
        EXX                                                     
        LD B, delay                                      
        DJNZ$                                               
        EXXR.L.A.                                                     
        LD E,A                                             
        SBC A,A                                             
        AND D                                               
        0UT (#FE),A                                         
                                                                
 0UT (#FE),A                                         
                                                                
        LD А,E ┐                                       
        RLA │                                       
        LD E,A │ repeat 7 times                       
        SBC A,A │                                       
        AND D │                                       
        0UT (#FE),A ┘                                       
                                                                
        POP DE                                              
                                                                
        INC HL                                              
        DEC DE                                              
        LD A,D                                             
        0R EJP      NZ,L1                                           
                                                                
                                                                
────────────────────────────────────────────────────────────────
                     (С) RAINB0W S0FTWARE                       
────────────────────────────────────────────────────────────────
                                                                

Share your thoughts about the article