MSX Village forum

La Place des Développeurs [EN COURS] Jouer des Bribes Audio ADPCM en continu sur le Music Module. Comment Charger et jouer des Bribes AUDIO sans discontinu.

igal Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++

Inscrit le : 29/07/2010 à 17h19

Messages: 5492

Le 12/10/2014 à 19h38
Lors de mes investigations sur la création d'un Scroll graphique en continu, je me suis retrouvé confronté à un problème de taille puisqu'il s'avère impossible d'utiliser un Player Audio pour tirer le meilleur parti du MSX.

J'ai donc pour idée de trouver une solution permettant le chargement de Fragments Audio qui donneraient l'illusion d'une lecture en continue tout en laissant la possibilité d'intercaler d'autres opérations entre chaque chargement Audio.

Pour faire simple, je voudrais faire ceci:

1) Je charge un fragment AUDIO
2) Je joue le fragment AUDIO.

La véritable difficulté je pense est de "tomber syncrho" à chaque chargement de bribe Audio.

J'ai pensé à l'approche suivante.

0 BLOAD"AUDIO ALPHA.PCM" GOTO 40
10 BLOAD"BRIBE AUDIO.PCM"
20 BLOAD"VIDEO,SCC",S
30 IF TIME > ou = 1 THEN 20 ELSE 40
40 TIMER = 0 : PLAY"BRIBE AUDIO" : GOTO 10

J'avais extrait une partie de programme contenu dans le Manuel de Service du Music Module.
Par ici => http://www.msxvillage.fr/forum/topic.php?id=1673&pt=1

Voici le contenu:
Code TEXT :
 
20 CLEAR 100,&HCFFF:DEFUSR=&HD002: GOSUB 2260
 
110 LOCATE 5,13: PRINT"6..Sample"
 
190 OUT &HC0,A: OUT &HC1,D: RETURN
 
1570 CLS: PRINT "Full Memory sampling test"
1580 LOCATE 5,5: PRINT"Press a key to record sample"
1590 IF INKEY$=""THEN1590
1600 LOCATE 5,7: PRINT"Recording now"
1610 REC=2700: RESTORE 1620
1620 DATA 19,00,04,FF,04,80,07,68
1630 DATA 08,00,09,00,0A,00,0B,FF
1640 DATA 0C,1F,0D,E1,0E,00,07,E8
1650 FOR N=1 TO 12
1660 READ A$: A=VAL ("&H"+A$)
1670 READ D$: D=VAL ("&H"+D$)
1680 GOSUB 190
1690 NEXT N
1700 FOR N=1 TO REC: NEXT
1710 A=7:D=&H68: GOSUB 190
1720 LOCATE 5,7: PRINT"Playing Now"
1730 RESTORE 1740
1740 DATA 19,08,04,FF,04,80,07,20
1750 DATA 08,00,09,00,0A,00,0B,FF
1760 DATA 0C,1F,10,EC,11,51,12,FF
1770 DATA 07,B0
1780 FOR N=1 TO 13
1790 READ A$:A=VAL("&H"+A$)
1800 READ D$:D=VAL("&H"+D$)
1810 GOSUB 190
1820 NEXT N
1830 FOR N=0 TO REC: NEXT
1840 LOCATE 5,7: PRINT"Repeating now"
1850 LOCATE 0,22: PRINT" Press any key to abort"
1860 IF INKEY$="" THEN 1860
1870 DATA 07,&HA1,07,&H20
1880 RESTORE 1870: READ A,D:GOSUB 190:READ A,D:GOSUB 190
1890 RETURN
 
2260 RESTORE 2310
2270 FOR P=&HD000 TO &HD026
2280 READ D$: POKE P,VAL ("&H"+D$)
2290 NEXT
2300 RETURN
2310 DATA 00,00,F3,21,00,40,DD,21
2320 DATA 00,00,E5,DD,E5,3E,02,CD
2330 DATA 0C,00,01,00,00,DD,E1,E1
2340 DATA 4F,DD,09,23,7C,FE,C0,20
2350 DATA E9,DD,22,00,D0,FB,C9
 
 


On peut trouver le listing complet en page 18 du Manuel de service ici => http://msx.hansotten.com/uploads/msxdocs/philipsnms12051160sm.pdf




Tiens... voila du boudin, voila du boudin, voila du boudin... :siffle
z80 Membre non connecté

Villageois

Rang

Avatar

Inscrit le : 17/05/2013 à 22h52

Messages: 956

Le 12/10/2014 à 20h14
Laisse tomber, tu ne peux pas jouer un sample et en charger un autre en même temps.


TurboR GT (1Mo), CANON V20! ( en kit, modif 2+ en cours) :top
Pas encore retrouvés: V9990, Grafx9000, SUNRISE IDE 2x CF, SUNRISE MOONSOUND, FM PAC, MUSIC MODULE, NMS8280, SD SNATCHER,... :\'(
   
ericb59 Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++ Groupe : Shoutbox

Inscrit le : 17/04/2012 à 10h25

Messages: 5492

Le 12/10/2014 à 20h49
L'amis Igal se croit sur Amiga ! :D


banniere-ericb59e
Site web    
Metalion Membre non connecté

Conseiller Municipal

Rang

Avatar

Inscrit le : 23/12/2009 à 15h32

Messages: 1488

Le 13/10/2014 à 11h03
z80 :
Laisse tomber, tu ne peux pas jouer un sample et en charger un autre en même temps.


Alors ça mon cher z80, Igal ne se laisse pas du tout arrêter par ce genre de vérité !

Par expérience, il vaut mieux le laisser arriver lui même à ses propres conclusions. :lol

Au passage, il découvre d'ailleurs parfois certaines choses intéressantes ...




MSX1: Daewoo DPC-200 / Yamaha CX5M
MSX2: Sony HB-F9P
MSXVR
Vidéo: V9990 (GFX-9)
Audio: MSX-Music (FM-PAC) / MSX-Audio (Audiowave) / OPL4 (Monster Sound FM Blaster) / OPNB (Neotron)
   
Bastion Rebel Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : Shoutbox

Inscrit le : 21/09/2013 à 07h42

Messages: 1721

Le 13/10/2014 à 18h02
salut

je me souvient d'un jeu sur MSX qui pendant un chargement jouais un morceau (PSG) inconvenant le FDD était toujours allumé maintenant un PCM ??? ca doit être possible !! sous dos2 avec MGS la musique n'est pas interrompu par le FDD ni le HDD !!! maintenant sous basic !! y as pas une instruction 'INTERUP' ou quel que chose dans le genre !! je crois bien !!


TURBO-R FS-A1ST 512/128ko MSX2+ NMS 8250 F4 /Fix Audio /Ram 1/4Mb VDP9958 VRAM 192ko 2FDD SANYO WAVY PHC35J MSX2 NMS 8280 Ram 4Mb VDP9938 VRAM 192ko 2FDD NMS 8250 128/128ko 2FDD VG8235/39 128/128ko 1FDD SONY HB-F700D MSX1 MC810 32/16k VG 8020 64k HB75F 64k HX-22 64k RS232/ CX5M 32k HB501F EXT : My Exp 4X/[b] MegaFlashSCC 512ko/BERT R2/BEER CF/SUNRISE 2CF/FUNRICE V2.01/MAXIOL/MEGASCSI HDD-CD/SDMSX 1SD/FMPAC SRAM/NMS1205+1160/RS 232 Harukaze/GR8NET/DOS2/ HOMER V2 RAM512ko/Floppy Pack/MAXduino/ROM1664/FM Pak /GR8NET /AMIGA/ PC/ RaspB Pi(B) / ARDUINO
E-mail    
TurboSEB Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++ Groupe : Shoutbox

Inscrit le : 08/08/2010 à 20h57

Messages: 5799

Le 13/10/2014 à 18h31
Avec Igal :glass, RIEN n'est impossible meme si c'est improbable , sauf si il ne l'a pas tester et démonter sous toutes les coutures :D

Et si vous voulez tester du multiprocesseur, pourquoi ne pas utilisé deux MSX en superimpose ^^
(Rhaaa, 2 HBG900 connecter en serie ^^)

Le Music MODULE , c'est une carte son avec son processeur, sa memoire Sample, sa sortie son , sa propre vie en somme , alors avec mon faible niveau ment... d'inteligence en electronique, j'imagine que ca doit etre comme un player MP3, j'entens par la que les données son ne passent pas par le bus ordinateur, donc j'imagine alors que celane doit "presque" pas le ralentir , je me trompe ou pas? Edité par TurboSEB Le 13/10/2014 à 18h51



MSX 1&2 + Moniteurs+divers (environ 0.70Tonnes)
   
z80 Membre non connecté

Villageois

Rang

Avatar

Inscrit le : 17/05/2013 à 22h52

Messages: 956

Le 13/10/2014 à 20h29
On ne peut pas écrire dans sa RAM pendant la phase lecture.
Si vous voulez faire ça alors il faut installé le module son d'une super Famicom (Nintendo 16bits). Lui il est 100% autonome une fois chargé avec les données musicales.


TurboR GT (1Mo), CANON V20! ( en kit, modif 2+ en cours) :top
Pas encore retrouvés: V9990, Grafx9000, SUNRISE IDE 2x CF, SUNRISE MOONSOUND, FM PAC, MUSIC MODULE, NMS8280, SD SNATCHER,... :\'(
   
MSXlegend Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : Shoutbox

Inscrit le : 18/06/2010 à 22h42

Messages: 5833

Le 13/10/2014 à 21h29
Sur turbo-r ça devrait être possible qui sait. Mais sur un simple msx2+, a moins de trouver une astuce faut voir !!
Igal, hate de voir le resultat de tes experiences :)


Createur du KCX Bluetooth emitter au format cartouche compatible stereo moonsound
z80 Membre non connecté

Villageois

Rang

Avatar

Inscrit le : 17/05/2013 à 22h52

Messages: 956

Le 13/10/2014 à 21h39
Malheureusement le Turbo-R ne changera rien à l'affaire...


TurboR GT (1Mo), CANON V20! ( en kit, modif 2+ en cours) :top
Pas encore retrouvés: V9990, Grafx9000, SUNRISE IDE 2x CF, SUNRISE MOONSOUND, FM PAC, MUSIC MODULE, NMS8280, SD SNATCHER,... :\'(
   
igal Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++

Inscrit le : 29/07/2010 à 17h19

Messages: 5492

Le 13/10/2014 à 21h52
Pour le moment je ne sais pas du mais doit être possible de charger un Music module pendant que l'autre lit le sample et cela alternativement.

Le problème c'est qu'il faut deux Music module.

Il est aussi possible de jouer une musique sur le moonsound sans être interrompu par les accès disque.
J'avais utilisé je ne sais plus quel logiciel sous dos pour lancer la musique (le logiciel se nome magic quelque chose). Ça peut être une alternative même si c'est pas le but initial.

Pour revenir aux samples je pensai charger/lire alternativement des segments adpcm très courts de sorte à donner l'illusion d'une d'une lecture sans interruption remarquable.

Si vous avez une idée farfelue :)

http://www.msx.org/forum/development/msx-development/playing-samples-msx?page=1 Edité par igal Le 15/10/2014 à 15h50


Tiens... voila du boudin, voila du boudin, voila du boudin... :siffle
igal Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++

Inscrit le : 29/07/2010 à 17h19

Messages: 5492

Le 15/10/2014 à 16h01
Voici un post de NYYRIKKI daté de 2005.

Le Music Module et le Covox sont du voyage :top

Le sujet est ici => http://www.msx.org/forum/development/msx-development/playing-samples-msx?page=1

Code TEXT :
 
Playing samples on MSX & Z80. 0.9b Made by: NYYRIKKI 2005
---------------------------------------------------------
 
There are many ways to play samples on MSX. MSX-Audio and Moonsound has even 
dedicated hardware to play samples, but these hardware solutions are not in 
scope of this document.
 
From this document you'll find, how to play samples following on devices:
 
- Covox / SIMPL
- MSX tR PCM
- Music Module
- Key click
- MSX-Music
- PSG
- Konami SCC
 
At the end of the document you'll find also some tips to get timing right.
 
In this document every example plays 8bit unsigned sample located in 
#C000-#CFFF at about 8KHz frequency. To load these examples from BASIC, 
you can use following program:
 
10 'LOADER.BAS
20 IF PEEK(&HF677)<>&HD4 THEN POKE &HF677,&HD4:POKE&HD400,0:RUN"LOADER.BAS"
30 BLOAD"COMPILED.BIN",R ' Run initialization code.
40 BLOAD"SAMPLE.DAT" ' Load sample data to #C000-#CFFF
50 A=USR(0) ' Play sample
 
In MSX tR you can generate the test sample data by writing following line:
CALL PCM REC (@&HC000,&HCFFF,3):SAVE"SAMPLE.DAT",&HC000,&HCFFF
 
If you don't have tR, then import the data from Amiga, PC, Mac or some 
other computer.
 
Let's start from easy ones...
 
Covox / SIMPL
-------------
 
Covox aka SIMPL is easy to build hardware, that is connected to printer port.
Here is routine, that plays sample using this device:
 
;------------------------------------
 
DEFB #FE
DEFW BEGIN
DEFW END
DEFW BEGIN
 
ORG #D000
 
BEGIN:
 
LD HL,PLAY
LD (#F39A),HL
RET
 
PLAY:
DI
LD HL,#C000;Start address
LD BC,#1000;Lenght
 
PLAYLOOP:
LD A,(HL)
INC HL
OUT (#91),A;8-bit unsigned data to printer port.
EXX
LD B,60
WAIT:DJNZ WAIT
EXX
DEC BC
LD A,B
OR C
JP NZ,PLAYLOOP
 
RET
 
END:
;-------------------------------------------------------------------
 
 
 
 
MSX tR PCM output
-----------------
...works same way as Covox/SIMPL so routine above can be used.
OUT (#91),A need to be changed to OUT (#A4),A
 
 
Music-Module
------------
 
Music-Module has 8-bit DAC as well, but it needs to be activated first. Here
is a sample routine for Music-Module:
 
 
;------------------------------------
 
DEFB #FE
DEFW BEGIN
DEFW END
DEFW BEGIN
 
ORG #D000
 
BEGIN:
 
LD HL,PLAY
LD (#F39A),HL
INIT:
LD A,#18
OUT (#C0),A
LD A,1
OUT (#C1),A
RET
 
PLAY:
DI
LD HL,#C000
LD BC,#1000
 
PLAYLOOP:
LD A,(HL)
INC HL
OUT (#A),A
EXX
LD B,60
WAIT:DJNZ WAIT
EXX
DEC BC
LD A,B
OR C
JP NZ,PLAYLOOP
 
RET
 
END:
 
;-------------------------------------------------------------------
 
 
Key click
---------
 
Key click was used on many MSX1 games to play samples. As this output is only
1bit wide sound quality is bad. I suggest using PSG instead whenever it is
possible.
 
Key click bit is located in PPI port C, I/O port #AA/bit 7. However, in this
example we use PPI control register (I/O #AB) instead of writing the bit
manually. By changing the bit from 7 to 5 you can also use this routine to
save the sample as audio to cassette deck.
 
;------------------------------------
 
DEFB #FE
DEFW BEGIN
DEFW END
DEFW BEGIN
 
ORG #D000
 
BEGIN:
 
LD HL,PLAY
LD (#F39A),HL
RET
 
PLAY:
DI
LD HL,#C000
LD BC,#1000
 
PLAYLOOP:
LD A,(HL)
INC HL
 
ADD A,A
LD A,0
ADC A,14
OUT (#AB),A
 
EXX
LD B,60
WAIT:DJNZ WAIT
EXX
DEC BC
LD A,B
OR C
JP NZ,PLAYLOOP
 
RET
 
END:
 
;-------------------------------------------------------------------
 
 
 
MSX-Music
---------
 
MSX-Music has also 6bit output in each of 9 channels that can be used to play
samples. This is not anyway documented feature. I did some tests and it seems,
that #FF need to be written to OPLL test register #F (No, 9 is not enough) and
channel specific SELECT register (#20-#28) bits 1-4 should be set to 1. Also
#20 should be put to channel specific VOLINS register. (#30-#38) After this
bits 2-7 in LOWFRQ registers (#10-#18) can be used as 6bit digital output.
 
If you can't hear anything, execute CALL MUSIC first!
 
Bit 0 of SELECT register seems to be also digital output, but level is not
double compared to LOWFRQ bit7, so it can't be used as 7th bit. Because output
level is not very high, you may want to modify the routine to play on multiple
channels at a same time.
 
;------------------------------------
 
DEFB #FE
DEFW BEGIN
DEFW END
DEFW BEGIN
 
ORG #D000
 
BEGIN:
 
LD HL,PLAY
LD (#F39A),HL
INIT:
LD HL,#0FFF
CALL WRFM
LD HL,#203F
CALL WRFM
LD HL,#3020
CALL WRFM
RET
 
WRFM:
LD A,H
OUT (#7C),A
EX (SP),HL
EX (SP),HL
LD A,L
OUT (#7D),A
EX (SP),HL
EX (SP),HL
RET
 
PLAY:
DI
LD HL,#C000
LD BC,#1000
LD A,#10
OUT (#7C),A
 
PLAYLOOP:
LD A,(HL)
INC HL
OUT (#7D),A
EXX
LD B,60
WAIT:DJNZ WAIT
EXX
DEC BC
LD A,B
OR C
JP NZ,PLAYLOOP
 
RET
 
END:
 
;-------------------------------------------------------------------
 
 
 
PSG
---
PSG is available in every MSX, so it is quite a good choice for playing 
sample. In PSG sample playing need to be done following way:
 
Every channel frequency needs to be set to value 0. This causes frequency
generator to be switched off and sound output set to value defined by volume.
Now you can play sample by changing volume. This is anyway a bit problematic
as volume in PSG is not linear but can be calculated from formula: output
level = 2^-((15-volume)/2) 
 
This means that we need to find combinations that cause output level to be as
close as possible to 8bit values. Luckily Arturo Ragozini has already done
these calculations for us, so that we can use ready tables.
 
 
;------------------------------------
 
DEFB #FE
DEFW BEGIN
DEFW END
DEFW START
 
ORG #D000
 
BEGIN:
 
DB  00,01,02,03,04,03,05,03,04,05,06,06,05,06,06,06
DB  06,06,07,06,07,08,08,08,07,07,09,07,09,09,08,08
DB  09,09,08,09,09,09,09,09,10,10,10,10,09,09,10,10
DB  10,10,09,10,11,11,11,11,11,11,11,11,10,10,10,11
DB  11,11,11,11,11,11,11,12,11,11,12,12,11,12,11,12
DB  12,12,12,11,12,11,12,12,12,12,11,12,12,12,12,11
DB  12,13,12,13,11,13,13,13,13,13,13,11,13,13,13,13
DB  13,13,13,12,13,13,13,12,12,13,12,13,13,13,13,13
DB  13,12,13,13,13,13,13,13,13,14,13,13,14,14,14,14
DB  14,14,13,14,14,13,14,14,14,14,14,14,13,14,14,14
DB  14,14,14,13,14,14,13,14,14,13,13,14,14,14,14,14
DB  14,14,14,14,13,14,14,13,14,14,14,14,14,14,13,14
DB  14,14,15,14,15,15,15,15,15,15,15,15,15,15,15,15
DB  14,15,15,15,15,15,15,14,15,15,15,15,15,15,15,15
DB  15,15,15,15,15,15,15,15,15,15,15,14,15,14,14,14
DB  14,14,15,15,14,15,15,14,15,15,15,15,15,15,15,14
 
DB  00,00,00,00,00,02,00,02,02,03,01,02,04,04,03,04
DB  04,05,04,05,05,02,03,04,06,06,01,06,02,03,06,07
DB  05,06,07,06,06,06,07,06,04,04,05,06,08,07,06,06
DB  07,06,08,07,03,04,03,04,04,05,05,05,08,09,09,07
DB  07,07,08,07,08,08,08,02,08,09,03,05,09,05,08,06
DB  06,07,06,10,07,09,08,07,08,08,09,08,08,09,08,10
DB  09,00,08,01,10,02,03,04,04,05,06,10,06,06,06,07
DB  06,07,07,10,08,08,07,11,11,08,11,08,09,09,09,08
DB  09,11,09,09,10,10,10,10,10,00,10,09,02,02,04,03
DB  04,04,11,05,05,11,07,07,07,07,07,08,10,08,08,08
DB  08,08,09,11,09,09,12,08,09,12,11,09,10,10,09,10
DB  10,10,10,09,11,10,10,12,10,10,11,11,11,10,12,11
DB  11,11,00,11,01,02,03,04,03,04,04,05,05,05,06,07
DB  12,07,07,07,08,07,08,12,08,08,08,09,08,09,09,09
DB  08,09,09,09,09,10,10,09,10,10,10,13,09,13,13,13
DB  13,13,10,11,13,11,10,13,11,11,11,11,11,10,10,12
 
DB  00,00,00,00,00,00,00,01,01,00,00,00,01,00,02,02
DB  03,02,01,04,01,01,01,01,03,04,00,05,01,01,04,01
DB  01,00,04,02,03,04,01,05,01,02,01,00,02,06,03,04
DB  01,05,06,04,00,00,02,02,03,02,03,04,06,02,03,02
DB  03,04,00,05,02,03,04,00,05,00,02,00,03,02,07,01
DB  02,00,04,00,03,07,00,05,02,03,08,04,05,00,06,07
DB  03,00,07,00,08,01,01,01,02,01,00,09,02,03,04,01
DB  05,03,04,07,01,02,06,01,02,05,04,06,02,03,04,07
DB  05,07,06,06,00,01,02,03,04,00,05,08,00,01,00,02
DB  02,03,00,03,04,03,00,01,02,03,04,00,09,02,03,04
DB  04,05,00,08,02,03,00,07,05,03,09,06,00,01,07,03
DB  04,04,05,08,10,06,06,08,07,07,00,00,01,08,09,04
DB  05,05,00,06,00,00,00,00,02,02,03,02,03,04,03,00
DB  01,02,03,04,00,05,02,06,04,04,05,00,06,02,03,04
DB  07,05,05,06,06,00,01,07,03,04,04,00,08,02,03,04
DB  04,05,07,00,06,01,08,07,04,05,05,06,06,09,09,11
 
 
START:
LD HL,PLAY
LD (#F39A),HL
INIT:
LD BC,#5A0
XOR A
INITLOOP:
OUT (C),B
OUT (#A1),A
DJNZ INITLOOP
OUT (C),A
OUT (#A1),A
RET
 
PLAY:
LD C,#A1
EXX
DI
LD HL,#C000
LD BC,#1000
 
PLAYLOOP:
LD A,(HL)
INC HL
 
EXX
LD L,A
LD H,#D0
ld b,(hl)
inc h
ld e,(hl)
inc h
ld h,(hl)
ld a,8
out (#A0),a
inc a
out (c),b
out (#A0),a
out (c),e
inc a
out (#A0),a
out (c),h
 
LD B,50
WAIT:DJNZ WAIT
EXX
DEC BC
LD A,B
OR C
JP NZ,PLAYLOOP
 
RET
 
END:
 
;-------------------------------------------------------------------
 
 
 
Konami SCC
----------
 
In Konami SCC you have theoretically three different methods to play sample.
As SCC plays actually 32 byte 8bit signed samples, first idea would be
updating the sample memory at same speed as SCC plays it. This is anyway very
hard to get right because we can not know where SCC is actually playing and we
can not reset the pointer either. Because of the hard implementation this idea
is skipped.
 
Second method is to use same kind of volume techniques as we used on PSG
sample playing. In SCC the volume (0-15) is linear, so tables are not needed.
To implement full 8-bit output we need at least 2 samples. One that has full
volume all the time (upper 4bits) and another sample with full volume/16
(lower 4bits). This kind of implementation can be found from example 1. 
 
Because SCC has signed samples, full volume is either up or down from zero
level. To go to both directions, we need 4 samples. This kind of advanced
implementation can be found from example 2. This also gives double volume
compared to 2 sample version.
 
One important thing to know is that change of volume is not implemented
immediately in SCC. Normally it is changed when next byte from sample memory
is played, but writing value to frequency causes current byte to be started
again. As in this example we write values very quickly to frequency registers
the internal sample counter does not actually move at all.
 
Third method is a variation of first method. As we don't know where SCC is
playing, let's update the whole sample memory with one and same new value.
To make sample rate not variable in low sample rates we first stop SCC from
reading sample memory. This can be done by writing value less than 9 to
frequency. Now we can update sample RAM so, that output does not change.
After sample RAM has been updated, we start SCC internal counter so that
value (where ever the counter was) is sent to output. This routine can be
found below as example 3.
 
Please note, that at least at time of writing this document, most (if not all)
of MSX emulators work wrong when it comes to SCC details. This may cause some
minor misbehaviour.
 
 
Example1:
 
;------------------------------------
 
SLOT:EQU #1;SCC Slot ID
 
DEFB #FE
DEFW BEGIN
DEFW END
DEFW BEGIN
 
ORG #D000
 
BEGIN:
LD HL,PLAY
LD (#F39A),HL
INIT:
LD A,SLOT
LD H,#80
CALL #24
 
LD A,#3F;Move to SCC page
LD (#9000),A
 
LD HL,#9800
LD DE,#9801
LD BC,#20
LD (HL),128;Max volume (=-128) sample
LDIR
LD C,#20
LD (HL),248;Max volume / 16 (=-8) sample
LDIR
 
LD HL,#FFFF;Set low frequency for both samples
LD (#9880),HL
LD (#9882),HL
 
LD A,3
LD (#988F),A;Enable channels 1&2
 
RET
 
PLAY:
LD HL,#FFFF
EXX
 
LD HL,#C000
LD BC,#1000
 
PLAYLOOP:
LD A,(HL)
INC HL
EXX
LD D,A
RLCA
RLCA
RLCA
RLCA
LD E,A
LD (#988A),DE;Volume for sample 1&2
LD (#9881),HL;Update frequency for sample 1&2
LD B,55
WAIT:DJNZ WAIT
EXX
DEC BC
LD A,B
OR C
JP NZ,PLAYLOOP
 
RET
 
END:
;-------------------------------------------------------------------
 
Example2:
 
;------------------------------------
 
SLOT:EQU #1;SCC Slot ID
 
DEFB #FE
DEFW BEGIN
DEFW END
DEFW BEGIN
 
ORG #D000
 
BEGIN:
LD HL,PLAY
LD (#F39A),HL
INIT:
LD A,SLOT
LD H,#80
CALL #24
 
LD A,#3F
LD (#9000),A
 
LD HL,#9800
LD DE,#9801
LD BC,#20
LD A,C
LD (HL),127
LDIR
LD C,A
LD (HL),8
LDIR
LD C,A
LD (HL),128;-128
LDIR
LD C,A
LD (HL),248;-8
LDIR
 
LD HL,#FFFF
LD (#9880),HL
LD (#9882),HL
LD (#9884),HL
LD (#9886),HL
 
LD A,15;Enable channels 1-4
LD (#988F),A
 
RET
 
PLAY:
DI
LD HL,#C000
LD BC,#1000
 
PLAYLOOP:
LD A,(HL)
INC HL
EXX
ADD A,A
PUSH AF
LD H,A
RLCA
RLCA
RLCA
RLCA
LD L,A
LD DE,0
POP AF
CALL C,CFLGUP
CALL NC,CFLGDOWN
LD (#988A),HL
LD (#988C),DE
LD HL,#FFFF
LD (#9881),HL
LD (#9883),HL
 
LD B,44
WAITDJNZ WAIT
 
EXX
DEC BC
LD A,B
OR C
JP NZ,PLAYLOOP
 
RET
 
CFLGDOWN:;HL=DE : DE=-HL
LD A,H
CPL
LD H,A
LD A,L
CPL
LD L,A
INC HL
 
EX DE,HL
RET
 
CFLGUP: ;JUST WASTE AS MUCH TIME AS CFLDOWN ROUTINE DOES
LD A,A
LD A,A
LD A,A
LD A,A
EX AF,AF'
INC BC
CPL
SCF
RET
END:
 
;-------------------------------------------------------------------
 
Example3:
 
;------------------------------------
 
 
SLOT:EQU #1;SCC Slot ID
 
DEFB #FE
DEFW BEGIN
DEFW END
DEFW BEGIN
 
ORG #D000
 
BEGIN:
 
LD HL,PLAY
LD (#F39A),HL
INIT:
LD A,SLOT
LD H,#80
CALL #24
 
LD A,#3F
LD (#9000),A
 
LD HL,0
LD (#9880),HL
 
LD A,15
LD (#988A),A
 
LD A,1
LD (#988F),A
RET
 
 
PLAY:
DI
LDHL,#9881
LDDE,0C000H
LDBC,1000H
PLAYLOOP:
LDA,(DE)
XOR128; Convert to signed data
INCDE
LD(HL),0; Stop output update
EXX
LDHL,9800H
LDDE,9801H
LD(HL),A
 
LDI; 32 x LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
LDI
 
LD B,16
WAIT:DJNZ WAIT
 
EXX
LD(HL),#FF;Update output
DECBC
LDA,B
ORC
JPNZ,PLAYLOOP
RET
 
END:
 
;-------------------------------------------------------------------
 
 
Few words about sample timing...
--------------------------------
 
All these examples have been timed using CPU. This is ok as long as we work
with non over clocked computers and we don't want to multitask. If this kind
of activity is required then external timer is a good idea. External timer is
 also quite a big help when we want to play notes on samples.
 
Standard MSX1 is worst case scenario as it usually does not have anything that
 you could use for sample timing. Only timer available is 50/60Hz VDP
interrupt, that is awfully too slow for sample purposes.
 
In MSX2 VDP's Horizontal Retrace Flag in status register 2 can be used to get
about 15.6KHz frequency. This can be very useful especially if you are
planning to do VDP tricks at a same time you play sample.
 
If you are not afraid of extreme tricks you may also use MSX2 real time clock
for sample timing. This means, that you first need to detect/set VDP 50/60HZ
mode. Then make a fast custom interrupt routine that calculates real time
using VDP interrupts. Then you need to synchronize Real-time clock time to
VDP clock and set RTC to test mode by using RTC register #E. This way you
can get 16 KHz timer. After playing sample, you need to restore RTC and
synchronize time back to it as users really don't like to get their clock
messed up!
 
MSX tR has sample timer located at I/O ports. #E6 & #E7 In MSX tR A1GT you
can use also MIDI interrupts to play sample.
 
Many external devices like Music-Module, RS-232 interfaces, Disk drive
interfaces, MIDI interfaces etc. have also different kind of timers. If you
require such interface, you might want to use these timers as well. Best
timers can also generate interrupts so, that you can do sample playing at
background.
 
~NYYRIKKI
 


Tiens... voila du boudin, voila du boudin, voila du boudin... :siffle
igal Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++

Inscrit le : 29/07/2010 à 17h19

Messages: 5492

Le 15/10/2014 à 19h38
Qui peut transformer ces programme en BASIC s'il vous plait :D
Une fois en Basic, je pourrais tester différentes façons jusqu'à trouver la solution la plus acceptable.

Code TEXT :
 
Covox / SIMPL
-------------
 
Covox aka SIMPL is easy to build hardware, that is connected to printer port.
Here is routine, that plays sample using this device:
 
;------------------------------------
 
DEFB #FE
DEFW BEGIN
DEFW END
DEFW BEGIN
 
ORG #D000
 
BEGIN:
 
LD HL,PLAY
LD (#F39A),HL
RET
 
PLAY:
DI
LD HL,#C000;Start address
LD BC,#1000;Lenght
 
PLAYLOOP:
LD A,(HL)
INC HL
OUT (#91),A;8-bit unsigned data to printer port.
EXX
LD B,60
WAIT:DJNZ WAIT
EXX
DEC BC
LD A,B
OR C
JP NZ,PLAYLOOP
 
RET
 
END:
;-------------------------------------------------------------------
 


MSX tR PCM output
-----------------
...works same way as Covox/SIMPL so routine above can be used.
OUT (#91),A need to be changed to OUT (#A4),A



La même chose pour le Music Module cette fois :top
Code TEXT :
 
Music-Module
------------
 
Music-Module has 8-bit DAC as well, but it needs to be activated first. Here
is a sample routine for Music-Module:
 
 
;------------------------------------
 
DEFB #FE
DEFW BEGIN
DEFW END
DEFW BEGIN
 
ORG #D000
 
BEGIN:
 
LD HL,PLAY
LD (#F39A),HL
INIT:
LD A,#18
OUT (#C0),A
LD A,1
OUT (#C1),A
RET
 
PLAY:
DI
LD HL,#C000
LD BC,#1000
 
PLAYLOOP:
LD A,(HL)
INC HL
OUT (#A),A
EXX
LD B,60
WAIT:DJNZ WAIT
EXX
DEC BC
LD A,B
OR C
JP NZ,PLAYLOOP
 
RET
 
END:
 
;-------------------------------------------------------------------
 


Merci :à


Tiens... voila du boudin, voila du boudin, voila du boudin... :siffle
ericb59 Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++ Groupe : Shoutbox

Inscrit le : 17/04/2012 à 10h25

Messages: 5492

Le 16/10/2014 à 06h51
pour moi c'est du chinois. peux pas t'aider...
encore faut il que ça soit traduisible en Basic, ce qui n'est pas une évidence.


banniere-ericb59e
Site web    
Fabf Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++

Inscrit le : 24/08/2010 à 20h55

Messages: 4833

Le 16/10/2014 à 09h18
Même si c'est traduisible en basic ce sera jamais assez rapide pour que quelque chose d'audible en sorte.

Par contre c'est une bonne base pour un lecteur Covox en streaming. ^^
Metalion Membre non connecté

Conseiller Municipal

Rang

Avatar

Inscrit le : 23/12/2009 à 15h32

Messages: 1488

Le 16/10/2014 à 11h00
Le plus simple est de ne pas traduire en BASIC, mais de créer la routine en assembleur et de l'appeler par USR(x).

Ceci dit, il y a un point important pour toi dans la boucle : la lecture commence après l'instruction "DI" (arrêt de toutes les interruptions).
Ce qui veut dire qu'une fois que tu as lancé la lecture, l'ordinateur ne peut rien faire tant que la lecture n'est pas finie.

Je doute que tu arrives à quelque chose par ce moyen là. Edité par Metalion Le 16/10/2014 à 11h04


MSX1: Daewoo DPC-200 / Yamaha CX5M
MSX2: Sony HB-F9P
MSXVR
Vidéo: V9990 (GFX-9)
Audio: MSX-Music (FM-PAC) / MSX-Audio (Audiowave) / OPL4 (Monster Sound FM Blaster) / OPNB (Neotron)
   
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie