Author Topic: Some audio stuffs  (Read 4093 times)

dshadoff

  • Full Member
  • ***
  • Posts: 175
Re: Some audio stuffs
« Reply #75 on: July 01, 2016, 02:04:21 AM »
HuYaGonnaCall - Ghostbusters

esteban

  • Hero Member
  • *****
  • Posts: 24063
Re: Some audio stuffs
« Reply #76 on: July 01, 2016, 02:10:09 AM »
/HuFIN

(Close thread)
  |    | 

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Some audio stuffs
« Reply #77 on: July 01, 2016, 06:08:24 AM »
« Last Edit: July 01, 2016, 06:10:18 AM by Bonknuts »

touko

  • Hero Member
  • *****
  • Posts: 953
Re: Some audio stuffs
« Reply #78 on: July 01, 2016, 08:54:34 PM »
Quote
Hu2 ?
:lol: ,nice .

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Some audio stuffs
« Reply #79 on: July 03, 2016, 05:33:54 AM »
Ok, I'm making a fundamental change to the timing and update mechanism of the driver. The timings are much more relaxed in the next release (no more 262 vs 263 line per frame nonsense/worry). And the over head is less than 1% cpu resource. I'm also going to add a few more macros, as well as just a subroutine call information for bypassing macro usage (ran into this problem with the XM player I'm writing, outputting to this driver).

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Some audio stuffs
« Reply #80 on: July 03, 2016, 12:18:30 PM »
Alright.. I wrote a quick simple XM player for PCE. Here a pack of three files (just the roms) http://www.pcedev.net/XMPlay/XMPlay_Pack1.zip

 This is just to demonstrate interfacing the PCM Driver with a music engine. Note: The samples are converted as is (no post processing on them), so some of them are a little rough.

 Also, if anyone has the free time - recorded it from the real console and post here :D




 FYI: If you want to run it in an emulator, that's fine too. But I'm not interested in emulator recordings (it should be slight softer on the real system because of entering the filter threshold).

Edit: Fixed broken link.
« Last Edit: July 03, 2016, 04:51:45 PM by Bonknuts »

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Some audio stuffs
« Reply #81 on: July 03, 2016, 04:50:25 PM »
Another test pack: http://www.pcedev.net/XMPlay/HuXMPlay_Pack2.zip
Fletch and Axel_f definitely sound better on the real hardware.

 These packs are just to show off some stuffs. It's clear that some samples are getting crushed by played above 2x the 7khz driver. I didn't prep for that. More of a test to see which samples sound decent as is.

 The filtering effect should work in favor of the real hardware once I get a 15.6khz version up and running.

Dicer

  • Hero Member
  • *****
  • Posts: 1905
Re: Some audio stuffs
« Reply #82 on: July 03, 2016, 05:46:02 PM »
I'll give both packs a spin on real deal hardware tomorrow, looking forward to hearing it...


Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Some audio stuffs
« Reply #83 on: July 04, 2016, 07:54:08 AM »
I fixed a bug in the driver for channels 1-3 that have looping points (it would update based on channel 0 data, for the other channels - which could go into an infinite loop on the interrupt routine). Gonna move the update processor inside the last TIRQ call, so timing won't be a problem. Vblank interrupt still resync's the TIMER though. I also found that XM/MOD files tend to have the looping data inside the wavefile itself ("smpl<"), so I'm gonna update wav2sixbit util to use this. I release those updates soon.



 I'm gonna make official thread for the PCM drivers (yes, there will be multiple versions), which I'll update when they mature. So this thread is still for discussing WIP PCM stuffs/concepts.

 As of now, since the first PCM Driver incarnation seems to be working quite well - I'm gonna start the 15.6khz version. The approach is a little different. Here's a basic driver setup:

Code: [Select]




      ;call                   ;8
     
      jmp [pointer]           ;7
     
active.part.one
      pha                     ;3
       
      phy                     ;3
      lda $0000               ;6
   
 
.RCR
      ;// RCR routine
      inc <IndexRCR               ;6
      bne .change.active.part     ;2
      st0 #RCR                    ;5
      sty $0002                   ;6
      lda <VDC_REG                ;4
      sta $0000                   ;6
                                  ; = 29
                                 
                                  ;42 cycles for overhead (includes INT call itself)
                                 
                                  ;29+42 = 72 * 262 = 18,864 or 15.8% cpu
     
.PCMDriver
      dec <DriverCnt    ;6
      beq .reload       ;2
     

.re-entry
      ldy <Bffr_IY      ;4
      inc <Bffr_IY      ;6
     
                        ;18


      stz $800
      lda buffer1,y
      sta $806

      lda #$01
      sta $800
      lda buffer2,y
      sta $806

      lda #$02
      sta $800
      lda buffer3,y
      sta $806

      lda #$03
      sta $800
      lda buffer4,y
      sta $806
                      ; 66 cycles
                     
                      ; 66+18 = 84
                      ; @256 times = 21504 cycles or 18% cpu resource
                     
                      ; Note: 21.5% for 6 channels.

      ply             ;4
      pla             ;4
  rti                 ;7

     
.reload
      dec <CounterTableIY
    bpl .NoResetIY
      lda #$5
      sta <CounterTableIY
.NoResetIY     
      ldy <CounterTableIY
      lda .CounterTable,y
      sta <DriverCnt
    jmp .re-entry

.CounterTable
      .db 43,44,44,43,44,44

Here's a version with a HDMA style system for doing Hint FX.

Code: [Select]




      ;call                   ;8
     
      jmp [pointer]           ;7
     
active.part.one
      pha                     ;3
     
      stz $402
      stz $403
      lda <BG0.l
      sta $404
      lda <BG0.h
      sta $405
 
      phy                     ;3
      lda $0000               ;6
   
      ldy <IndexRCR
      lda Dolist,y
      beq .skip
                        ;// X scroll
      bit #$01 
      beq .next1
      st0 #$07
      lda Xoffset,y
      sta $0002
           
.next1                  ;// Y scroll
      bit #$02
      beq .next2
      st0 #$08
      lda Yoffset,y
      sta $0002

.next2                  ;// Sprite off/on, BG off/on
      bit #$04
      beq .next3
      st0 #$05
      lda VDC_disp,y
      sta $0002

.next3                  ;// BG color #0
      bit #$08
      beq .skip
      lda BG0.lsb,y
      sta <BG0.l
      lda BG0.msb,y
      sta <BG0.h
     
.skip

.RCR
      ;// RCR routine
      inc <IndexRCR               ;6
      bne .change.active.part     ;2
      st0 #RCR                    ;5
      sty $0002                   ;6
      lda <VDC_REG                ;4
      sta $0000                   ;6
                                  ; = 29
                                 
                                  ;42 cycles for overhead (includes INT call itself)
                                 
                                  ;29+42 = 72 * 262 = 18,864 or 15.8% cpu
     
.PCMDriver
      dec <DriverCnt    ;6
      beq .reload       ;2
     

.re-entry
      ldy <Bffr_IY      ;4
      inc <Bffr_IY      ;6
     
                        ;18


      stz $800
      lda buffer1,y
      sta $806

      lda #$01
      sta $800
      lda buffer2,y
      sta $806

      lda #$02
      sta $800
      lda buffer3,y
      sta $806

      lda #$03
      sta $800
      lda buffer4,y
      sta $806
                      ; 66 cycles
                     
                      ; 66+18 = 84
                      ; @256 times = 21504 cycles or 18% cpu resource
                     
                      ; Note: 21.5% for 6 channels.

      ply             ;4
      pla             ;4
  rti                 ;7

     
.reload
      dec <CounterTableIY
    bpl .NoResetIY
      lda #$5
      sta <CounterTableIY
.NoResetIY     
      ldy <CounterTableIY
      lda .CounterTable,y
      sta <DriverCnt
    jmp .re-entry

.CounterTable
      .db 43,44,44,43,44,44
^- Just one example. With the indirect jump, you can do all kinds of setups.

 So the base setup, no Hint FX, is 30% play 4 channels at 15.6khz. Of course, this doesn't include the frequency scaling. That's all done outside this routine. This is just one of many types of 15.6khz setups.

 If you notice, the channel select operates take up some timing. That's unfortunate as they really didn't need to implement that type of system (they could have mapped all registers to their own unique addresses). But what that does mean, is that doing a 10bit paired channel output won't be much more resource (probably nearly the same). Just that it wouldn't be stereo, but you'd have 4 regular PCE channel that are stereo.

 The same setup, but with 10bit paired would save 34 cycles over head per sample (two samples) initially. But software volume costs +5 cycles, and mixing costs +7. So 48 cycles total overhead for soft channels (10bit method), but 34 cycles saved, so +14 cycles more or 3% more cpu resource. Mono, but 4 frequency scaling channels at a higher bit depth (6bits per channel, or 7bits with a little bit more resource).


 Anyway, so 30% for the "driver" part. If I can frequency scale four channels in 20% cpu or less (which should be doable), then I'll have hit my mark: 50% total cpu resource to playback 4 channels at 15.6khz. The quality should jump up dramatically. On the real system, there should be even more of a filter effect too since the playback rate will be higher. And on some emulators, it won't sound so good (they don't expect that high a DDA playback rate, and so will miss sample writes, etc). Ootake had a crappy artifact in DDA writes even at 7khz - did they fix that? As per usual, mednafen shouldn't have a problem.

Dicer

  • Hero Member
  • *****
  • Posts: 1905
Re: Some audio stuffs
« Reply #84 on: July 04, 2016, 08:18:08 AM »
Burn Rubber: Nice track, sounds appropriately retro
Destructive: Misleading title, I wanted to construct not destruct
Night Train: Really like this one, should be in a beat em up city level, and vocals nifty.

Axel F: well, makes me want a crazy frog bros OBEY title, maybe with pizza tossing
Empty Spaces 2: Not my scene, a bit too down tempo but still nice work
Fletch: Chevy chase would be proud
Out on a limb Fast/Slow: I actually prefer the down tempo version, very un-typical of me.




Now get me some 2-unlimited or ultra BPM mixes up in here and I'll be a happier camper.



Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Some audio stuffs
« Reply #85 on: July 04, 2016, 09:23:04 AM »
Find some decent 2 unlimited mods... then we talk.

 Someday, I want to do a PCE version of this demo:

Dicer

  • Hero Member
  • *****
  • Posts: 1905
Re: Some audio stuffs
« Reply #86 on: July 04, 2016, 10:22:48 AM »
Find some decent 2 unlimited mods... then we talk.

 Someday, I want to do a PCE version of this demo:
! No longer available


Short megamix
http://janeway.exotica.org.uk/release.php?id=53397

Magic Friend
http://lite.modarchive.org/index.php?request=view_by_moduleid&query=121776

And because I've always like this one
http://janeway.exotica.org.uk/release.php?id=50127
BLUEBOXING


ccovell

  • Hero Member
  • *****
  • Posts: 2245
Re: Some audio stuffs
« Reply #87 on: July 04, 2016, 12:26:13 PM »
If it helps -- probably not -- here is my writing loop in Old is Beautiful for playing 8-bit PCM.  I do double the channels (4) just to get a louder overall output.

Code: [Select]
Sample_Loop:
bbs0 <samp_interrupt,.no_sample_play
bbr0 <samp_on,.no_sample_play
.samp_loop:
smb0 <samp_interrupt ;Stop player from entering twice
lda [sampadd]
beq .sample_end_marker
tax
lsr a
lsr a
lsr a ;divide by 8!
sax
and #$07 ;top 3 bits
ldy #3
sty $0800   ;chan 3
sta $0806 ;Save sample!!
dey
sty $0800   ;chan 2
sta $0806 ;Save sample!!
dey
sty $0800   ;chan 1
stx $0806 ;Save sample!!
stz $0800
stx $0806 ;Save sample!!
incw <sampadd
rmb0 <samp_interrupt ;Stop player from entering twice

.no_sample_play:
rts
.sample_end_marker:
rmb0 <samp_on ;no more samples!
rmb0 <samp_interrupt ;Stop player from entering twice
rts

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Some audio stuffs
« Reply #88 on: July 05, 2016, 05:26:38 AM »
ccovell: How did I not know about this demo!?
Ok, I messed with that mode (7.16mhz with no h-filter) for years, but I could never figured out how to calculate the color values. What program or process did you use?

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Some audio stuffs
« Reply #89 on: July 05, 2016, 07:18:01 AM »
So I'm working on reducing the frequency scaling routine for the VDC int version. Here's the simple conversion of the timer one to it:
Code: [Select]
.loop
.sm17   lda #$00                                  ;2
.cn6    adc #$00                                  ;2
        sta (.sm17 - TIMER_PLAYER)+BASE_SM1+1     ;5       
.sm18   lda #$00                                  ;2
.cn7    adc #$00                                  ;2
        sta (.sm18 - TIMER_PLAYER)+BASE_SM1+1     ;5           
        tya                                       ;2
.cn8    adc #00                                   ;2
        tay                                       ;2
.sm20   lda $0000                                 ;5
        bmi .chn3_chk                             ;2 
        sta bffr,x                                ;5
        dex                                       ;2
        bne .loop                                 ;4

 But that's 42 cycles per channel: 42*246*4 = 43008 cycles or 36% cpu resource. Easy to implement, but too high.

 I need to get that cycle count down into the 20's.

 My two option are precalc code paths (using jump tables to keep the size down) or bit mask (they're long, but shouldn't eat too much memory; aka lsr mask, bcc skipsample).

Code: [Select]
      tst #nn, list,x ;8
      beq .skip       ;4/2
      iny
      iny
      iny
      iny             ;8
.skip
      lda abs,y       ;5
      sta bffr+x      ;5

8 of these in a row (self modifying code) followed by this:
Code: [Select]
      dex             ;2
      bne .loop       ;4
That gives 64 samples. So a reset of some addresses 4 times total (4*64 = 256 samples).
It's not bad. Base is 28 cycles a sample. The second part happens every 8 samples, so that overhead is 6/8 = .75 cycles. And the overhead every 64 samples is less than 1 cycle per sample. So I'll round it up to 29 cycles per sample. That's 4*29*256 = 29696 cycles or 25% cpu resource.

 Better than 36%, but not quite the less-than-20% mark I'm looking for. I think I might have to do code paths to get it lower...