PCM player using SCC (Development MSX Fora)MSX Resource Center            
            
English Nederlands Espa�ol Portugu�s Russian         
 Nieuws
   Voorpagina
  Nieuws archief
  Nieuws onderwerpen

 Informatie
   MSX Fora
  Artikelen
  Recensies
  Beursverslagen
  Fotoreportages
  Beurzen en meetings
  Enquêtes
  Links
  Zoek

 Software
   Downloads
  Webshop

 MRC
   Wie we zijn
  Kom bij ons team
  Doneren
  Policies
  Contact met het MRC
  Link naar Ons
  Statistieken

 Zoek
 
  

  

 Login
 

Gebruikersnaam

Wachtwoord




Ben je nog niet lid? Klik hier en word MSX vriend!


 Statistieken
 

Er zijn 63 gasten en 3 MSX vrienden online

Je bent een anonieme bezoeker.
 

MSX Fora


MSX Fora

Development - PCM player using SCC

Ga naar pagina ( Vorige pagina 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 Volgende pagina )
Schrijver

PCM player using SCC

ARTRAG
msx master
Berichten: 1737
Geplaatst: 21 Oktober 2007, 23:23   
You have mail
this is the new release according to latest info
;----------------------------------------------------------------------------
;----------------------------------------------------------------------------


        OUTPUT sccplay.rom
        org 4000h
        dw  "BA",START,0,0,0,0,0,0


Bank1   equ      05000h
Bank2   equ      07000h
Bank3   equ      09000h
Bank4   equ      0B000h


;-------------------------------------
; Entry point
;-------------------------------------
START:
        call powerup
        xor a
        call 005Fh

        ld  a,3Fh
        LD  (Bank3),A

Period  equ      9

; F sample   = 3,579,545Hz / 32 / (1+Period)
; F rotation = 32 * F sample;

        ld  hl,Period       ; F sample ch1 = 11186Hz
        ld  (9880h),hl

        ld  hl,32*Period+31 ; F sample ch4 = F sample ch1/32
        ld  (9886h),hl
         
    DISPLAY "Period of ch 1 is :",/D,Period
    DISPLAY "Period of ch 4 is :",/D,32*Period+31
        
        ld  a,15
        ld  (988Ah),a       ; volume ch1

        xor a
        ld  (988Bh),a       ; volume ch2
        ld  (988Ch),a       ; volume ch3
        ld  (988Dh),a       ; volume ch4
        ld  (988Eh),a       ; volume ch5

        ld  a,00011111b     ;   ALL channels active
        ld  (988Fh),a

        ld      hl,9800h+32*3   ; counter in channel 4
        ld      bc,32*256
.counter:
        ld  (hl),c
        inc hl
        inc c
        djnz  .counter
        
             ;RRB000XX
        ld  a,10000000b ; Rotate only CH4 & CH5 common waveform. Waveform will be rotated with CH4 freq.
        ld  (98E0h),a

.REWIND:
        xor a
.LOOP:
        inc a
        ld  (Bank2),a

        ld  hl, SAMPLE_START

        ex   af,af'
        ld  b,0
.page:
        push    bc

;;;;;;;;;;;;;;;;;;;;;;
;
;   do your stuff here
;   in less than        32 / F_sample ch1 seconds
;   but in more than     1 / F_sample ch1 seconds

        ld  b,170
.inner
        ld a,r
        out(99h),a
        ld a,128+7
        out(99h),a
        djnz      .inner

;
;;;;;;;;;;;;;;;;;;;;;;


.wait:
        ld      a,(9800h+32*3)
        or  a
        jr  nz,.wait        ; wait for a complete rotation on ch 4

        ld      de,9800h    ; wavetable ch1
        ld      bc,20h
        ldir

        pop bc
        djnz    .page
        ex   af,af'

        cp  (SAMPLE_END - SAMPLE_START + #1FFF)/#2000
        jr  nz,.LOOP
        jr  .REWIND
        ret


;-------------------------------------
;   Powerup routine for non-Z180 code.
;   set pages and subslot
;-------------------------------------
powerup:
        call    0x138
        rrca
        rrca
        and     0x03
        ld      c,a
        ld      b,0
        ld      hl,0xfcc1
        add     hl,bc
        or      (hl)
        ld      b,a
        inc     hl
        inc     hl
        inc     hl
        inc     hl
        ld      a,(hl)
        and     0x0c
        or      b

        ld      h,0x80
        call    0x24

        ret



;-------------------------------------
; Padding for rom player
;-------------------------------------
        DS (#6000 - $)


;-------------------------------------
; Sample data
;-------------------------------------
SAMPLE_START:
        incbin "handel3.wav",44, 56*1024
SAMPLE_END:


;-------------------------------------
; Padding, align rom image to a power of two.
;-------------------------------------

SAMPLE_LENGTH   equ SAMPLE_END - SAMPLE_START

    DISPLAY "Sample END  :",/A,SAMPLE_END 
    DISPLAY "Sample START:",/A,SAMPLE_START    
    DISPLAY "# Samples   :",/A,SAMPLE_LENGTH

        IF (SAMPLE_LENGTH <= #6000)
        DS (#6000 - SAMPLE_LENGTH)
        ELSE
        IF (SAMPLE_LENGTH <= #E000)
        DS (#E000 - SAMPLE_LENGTH)
        ELSE
        IF (SAMPLE_LENGTH <= #1E000)
        DS (#1E000 - SAMPLE_LENGTH)
        ELSE
        IF (SAMPLE_LENGTH <= #3E000)
        DS (#3E000 - SAMPLE_LENGTH)
        ELSE
        IF (SAMPLE_LENGTH <= #7E000)
        DS (#7E000 - SAMPLE_LENGTH)
        ELSE
        DS (#FE000 - SAMPLE_LENGTH)
        ENDIF
        ENDIF
        ENDIF
        ENDIF
        ENDIF



FINISH:


ARTRAG
msx master
Berichten: 1737
Geplaatst: 21 Oktober 2007, 23:59   
Rereading my old posts I've found an error

Quote:

Great!
Can you post also the asm of a working program?
I've the feeling that bluemsx does not emulate correctly this behaviours,
your code, tested on the real HW, could be used to spot problems in the
emulators.
Anyway, the fact that channels at 1920Hz can have offsets is a very good
news!!

Can I guess a way to work with them?

0a) compute the phases as you proposed in you previous posts
(ch1 == original signal subsampled by 4 on phase 1)
(ch2 == original signal subsampled by 4 on phase 2 - ch1)
(ch3 == original signal subsampled by 4 on phase 3 - ch2)
(ch4 == original signal subsampled by 4 on phase 4 - ch3)

0b) reset the volumes of the 4 channels

loop :

1) reset volumes of ch2,ch3,ch4 => prevent errors in the first 4 samples of each loop
2a) fill ch1
2b) set freq and volume in ch1 => sample 1 is well reproduced as only ch1 is active
2c) wait 1/7680 secs
3a) fill ch2
3b) set freq and volume in ch2 => sample 2 should be well reproduced as only ch1&2 are active
3c) wait 1/7680 secs
4a) fill ch3
4b) set freq and volume in ch3 => sample 3 should be well reproduced as only ch1,2&3 are active
4c) wait 1/7680 secs
5a) fill ch4
5b) set freq and volume in ch4 => sample 4 should be well reproduced as all chs are active
5c) wait 1/7680 secs
6) wait (32/1920-4/7680) secs (the complement to, in order to keep cycle accuracy)

8) goto 1

If it works standalone as cycle accurate loop, it can go in an interrupt too.
and in any cases steps from 1) to 5b) must be cycle accurate even when in interrupts

If it works, the time "wasted" in the int routine is 3/7680 secs, not a lot, without considering that in each pause of 1/7680 secs you can do VDP I/O



I was wrong in describing how to process input in order to get the channels:
The correct equations are:

ch1(1) = ph1(1);
ch2(1) = ph2(1) - ch1(1);
ch3(1) = ph3(1) - ch1(1) - ch2(1);
ch4(1) = ph4(1) - ch1(1) - ch2(1) - ch3(1);

for i=2:size(Y)/4
 ch1(i) = ph1(i)-ch2(i-1)-ch3(i-1)-ch4(i-1);
 ch2(i) = ph2(i)-ch1(i)-ch3(i-1)-ch4(i-1);
 ch3(i) = ph3(i)-ch1(i)-ch2(i)-ch4(i-1);
 ch4(i) = ph4(i)-ch1(i)-ch2(i)-ch3(i);
end



where Y is the input, phX is the input subsampled
on phase X and chX is channel X


nikodr
msx addict
Berichten: 491
Geplaatst: 22 Oktober 2007, 00:13   
artrag i am now uploading the rom file to the megaflash
will post you in a few minutes and tell you what is happening
nikodr
msx addict
Berichten: 491
Geplaatst: 22 Oktober 2007, 00:25   
It does not work for me,only strange colors appearing on screen and low noise is heard.I didn't hear any sound that i could understand...only some kind of noise,also the colors and shapes of colors were different from the ones bluemsx as a msx2 with konami scc mapper configuration appears on screen.

dvik
msx master
Berichten: 1339
Geplaatst: 22 Oktober 2007, 04:34   
After updating blueMSX to what NYYRIKKI said about the channels, the program still doesn't work. I read the source and these forum post and I can't at all understand how its intended to work. Why do you set the period of CH4 to 32x CH1 +31 ? And how do you know what samples are being played based on the values in CH4. Did someone test it on a real cart?
ARTRAG
msx master
Berichten: 1737
Geplaatst: 22 Oktober 2007, 07:17   
Well the idea was this:
The deformed channel rotate 32 times faster than its frequency.
If you set ch4 frequency at the vale you said, you should have that
the Freq of ch1 should be equal to the rotation frequency of ch4.
In this way for each sample played we get a step in the counter (ch4)
when ch4 passes from 0, we played 32 samples, so we can update ch1
wavetable
dvik
msx master
Berichten: 1339
Geplaatst: 22 Oktober 2007, 08:23   
Yeah, I understand the part where the wrap of CH4 drives updating of the samples in CH1 but not the math and how the channels are synchronized.
I'm working on modifying the app a little bit as well as updating the emulator and if I get something that I think may work I'll post it here.
dvik
msx master
Berichten: 1339
Geplaatst: 22 Oktober 2007, 09:08   
Some good progress, recorded in blueMSX: http://www.bluemsx.com/demos/sccplay_01.wav

I had to do both some hacking in the emulator and in ARTRAG's player. I'll clean up the player tomorrow night and post it here. Now its very hacky. If it works on a real MSX I think we've achieved something very amazing

ARTRAG
msx master
Berichten: 1737
Geplaatst: 22 Oktober 2007, 09:58   
My code is a blind experiment so it is by sure buggy
dvik, what was wrong in it ?


ARTRAG
msx master
Berichten: 1737
Geplaatst: 22 Oktober 2007, 10:53   
Ok, with the correction I did, all the volumes settings in the loop are unnecessary
I think that everything could be restated in this way:

ch1(1) = ph1(1);
ch2(1) = ph2(1) - ch1(1);
ch3(1) = ph3(1) - ch1(1) - ch2(1);
ch4(1) = ph4(1) - ch1(1) - ch2(1) - ch3(1);

for i=2:size(Y)/4
 ch1(i) = ph1(i)-ch2(i-1)-ch3(i-1)-ch4(i-1);
 ch2(i) = ph2(i)-ch1(i)-ch3(i-1)-ch4(i-1);
 ch3(i) = ph3(i)-ch1(i)-ch2(i)-ch4(i-1);
 ch4(i) = ph4(i)-ch1(i)-ch2(i)-ch3(i);
end


where Y is the input, phX is the input subsampled
on phase X and chX is channel X

1) set to zero the wave tables of the 4 channels

loop :

2a) load 32 bytes in ch1
2b) set freq in ch1 => sample 1 is well reproduced as only ch1 is active - in the first iteration -
2c) wait 1/7680 secs (the complement to, in order to keep timing accuracy)

3a) load 32 bytes in ch2
3b) set freq in ch2 => sample 2 should be well reproduced as only ch1&2 are active - in the first iteration -
3c) wait 1/7680 secs (the complement to, in order to keep timing accuracy)

4a) load 32 bytes in ch3
4b) set freq in ch3 => sample 3 should be well reproduced as only ch1,2&3 are active - in the first iteration -
4c) wait 1/7680 secs (the complement to, in order to keep timing accuracy)

5a) load 32 bytes in ch4
5b) set freq in ch4 => sample 4 should be well reproduced as all chs are active 
5c) wait 1/7680 secs (the complement to, in order to keep cycle accuracy)

6) wait (32/1920-4/7680 = 124/7680) secs (the complement to, in order to keep cycle accuracy)

7) goto loop

According to the equations, original samples should be correctly reproduced even after the reproduction of first 4 samples,
and even between two loop iterations (i.e. the output of 32 samples).

Again, if it works standalone as cycle accurate loop, it can go in an interrupt too, 
and in any case, steps from 2a) to 5b) must be cycle accurate even when in interrupts

If it works, the time "wasted" in the int routine is 3/7680 secs, not a lot, without considering that in each pause of 1/7680 secs you can do VDP I/O (you can fit about 25 outi in it)


manuel
online
msx guru
Berichten: 3531
Geplaatst: 22 Oktober 2007, 11:04   
dvik, please share the ROM file, so we can test on real machines and on openMSX.
nikodr
msx addict
Berichten: 491
Geplaatst: 22 Oktober 2007, 12:15   
I tested it on a real machine an msx2 philips NMS 8280 with a megaflash scc and only noice and some strange colors appeared.Can you send me the fixed rom dvik?

NYYRIKKI
msx master
Berichten: 1525
Geplaatst: 22 Oktober 2007, 15:15   
Quote:

I just checked: the info in NYYRIKKI's post seems to match the implementation in openMSX. Except for RR=11, in that case only channels 1-3 rotate and all channels are read-only.



I think that I might be wrong here. The documentation that I wrote here does not match what I remember I wrote down to my self... I'll check my memos again when I'm at home...

dvik
msx master
Berichten: 1339
Geplaatst: 22 Oktober 2007, 16:22   
I'll prepare the code and roms today. I worked quite late yesterday and had to go to sleep before I had something to share.
nikodr
msx addict
Berichten: 491
Geplaatst: 22 Oktober 2007, 16:25   
Great dvik.I wait to see the roms and upload them on megaflash.Would rom be possible to be used on a memory mapped machine with a scc+ ?
I was thinking about a execrom patched rom to be used on machines with memory mapper and test this on Scc+ to see if it works too?i have an scc+ from snatcher.
 
Ga naar pagina ( Vorige pagina 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 Volgende pagina )
 







(c) 1994 - 2008 Stichting MSX Resource Center. MSX is een trademark van MSX Licensing Corporation.