It is currently Sun Dec 17, 2017 12:44 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 48 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
PostPosted: Sun Aug 21, 2016 10:50 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5899
Location: Canada
Yeah, but that's just a phase accumulator again, just you've replaced the saw wave with a wavetable lookup, so it could be any wave. (With the saw, the "wavetable index" is your wavetable already.)

Though, if you did 4-bit waves, you'd only need a 16 x 16 table to do sample * volume * output level in a single lookup. That's probably a better way to do volume.

I was just coming at it trying to think if the "subtract 2 waves" idea could apply to anything else. Maybe not.


Top
 Profile  
 
PostPosted: Mon Aug 22, 2016 6:59 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19353
Location: NE Indiana, USA (NTSC)
Subtracting two saws gives you a variable duty cycle pulse wave, for some SID or VRC6 style sound.


Top
 Profile  
 
PostPosted: Mon Aug 22, 2016 6:52 pm 
Offline

Joined: Thu Aug 20, 2015 3:09 am
Posts: 298
I have the same communication difficulties as tepples, so let me clarify. I was replying to this:
rainwarrior wrote:
It operates at a much higher frequency than you could do in software, of course, so tuning might be an issue if you did something similar in software (i.e. ~150x lower samplerate).

I believe this to be incorrect, and that the code I posted implements the described behaviour: a software implementation of a clock divisor running at the same samplerate as the VRC6, with the caveat that it is limited to periods greater than approximately 172 cycles. The benefit of such an algorithm being that it eliminates audible aliasing.

If any of that is not the case, please point out the error in my logic.


Top
 Profile  
 
PostPosted: Mon Aug 22, 2016 7:13 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5899
Location: Canada
Oh, sorry, I misunderstood what you were implying with the sample. So the "clockslide" is really a variable entry point that determines the length of the sample loop?

So... that lets you adjust the samplerate directly to control the pitch of your generator, instead of having a fixed samplerate. Makes sense. I guess the pitch resolution would then be half the CPU rate. The high end of the pitch range might be a bit limited, though probably fine.

Limited to one channel, though, as you said. Hmm. Interesting approach though.


Top
 Profile  
 
PostPosted: Mon Aug 22, 2016 7:36 pm 
Offline

Joined: Thu Aug 20, 2015 3:09 am
Posts: 298
A clockslide produces a single cycle of delay per byte, down to a minimum of two cycles, so the pitch resolution is the full CPU rate.

EDIT: that site seems to be unstable, and I can't find another good explanation, so here's the general idea:

Code:
; C9 C9 C9 C5 EA
cmp #$C9 ; 2 cycles
cmp #$C5 ; 2 cycles
nop      ; 2 cycles

; C9 C9 C5 EA
cmp #$C9 ; 2 cycles
cmp $EA  ; 3 cycles

; C9 C5 EA
cmp #$C5 ; 2 cycles
nop      ; 2 cycles

; C5 EA
cmp $EA  ; 3 cycles

; EA
nop      ; 2 cycles

A jmp (indirect) or self-modifying jmp absolute into any point in a sequence of {C9} C5 EA will delay one cycle for every byte of clockslide executed, plus a constant (the cost of the jump plus the final nop, 5 or 7 cycles).


Top
 Profile  
 
PostPosted: Mon Aug 22, 2016 8:18 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5899
Location: Canada
Ah, I understand. I was just thinking of a line of NOPs.

Hmm, noticed this technique is actually described on the Wiki, but in an inappropriate article for it. Ha ha. Weird.


Top
 Profile  
 
PostPosted: Mon Aug 22, 2016 11:51 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7319
Location: Chexbres, VD, Switzerland
Blargg got working saw and square waves with DMC channel long ago, combiniing $4011 writes and DPCM it doesn't even require a mapper with a CPU-cycle timer IRQ, and can be done on NROM, and uses much less CPU.

The whole point I had making it on a fixed sample rate was to mix 2 or more channels.

I do not see how substracting saw waves get a saw wave with controllable volume. Anyhow, I fear aliasing might be awful with saw waves, and with general-purpose-4-bit waves as well.


Top
 Profile  
 
PostPosted: Mon Aug 22, 2016 11:53 pm 
Offline
User avatar

Joined: Sat Jul 12, 2014 3:04 pm
Posts: 950
Rahsennor wrote:
the Deflemask trick

What, polling $4015 for frame counter with interrupts masked?


Top
 Profile  
 
PostPosted: Tue Aug 23, 2016 6:21 pm 
Offline

Joined: Thu Aug 20, 2015 3:09 am
Posts: 298
Myask wrote:

Yes, that. The code I gave uses 100% CPU but runs at a variable rate, so it can't time notes and envelopes by itself. Interrupts would cause audible distortions, but polling can be synchronized with the PCM.


Top
 Profile  
 
PostPosted: Fri Aug 26, 2016 5:17 pm 
Offline
User avatar

Joined: Thu Jan 03, 2008 1:48 pm
Posts: 544
(Move to "NES Music" please. :) )


Top
 Profile  
 
PostPosted: Fri Aug 26, 2016 5:19 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5899
Location: Canada
Why? This thread is about programming, not music. (More thorough reponse here)

The only piece of music in this thread is the CV3 test I posted a ways in.


Last edited by rainwarrior on Fri Aug 26, 2016 5:22 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Fri Aug 26, 2016 5:21 pm 
Offline
User avatar

Joined: Thu Jan 03, 2008 1:48 pm
Posts: 544
rainwarrior wrote:
Why? This thread is about programming, not music.

The only piece of music in this thread is the CV3 test I posted a ways in.

"Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music."


Top
 Profile  
 
PostPosted: Sun Aug 28, 2016 5:20 am 
Offline
User avatar

Joined: Mon Nov 27, 2006 11:56 pm
Posts: 86
Location: Sollentuna, Sweden
"Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems."

This is very much a thread about a technichal issue related to programming the NES imho.

Much more so than related to NES music.


Top
 Profile  
 
PostPosted: Wed Aug 31, 2016 3:46 am 
Offline
User avatar

Joined: Fri Jan 24, 2014 9:05 am
Posts: 141
Location: Hungary
If sampling rate is an issue, you could try the method I used to get double the normally achievable rate with DMC interrupts (8 272Hz) by sitting in the IRQ handler enough to pump out another sample right in-between two consecutive IRQ-s. It takes more CPU, but you can also spend the time after the first sample to do your calculations and it requires no IRQ source to be in the cartridge.


Top
 Profile  
 
PostPosted: Wed Aug 31, 2016 3:07 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5899
Location: Canada
Interesting idea, though the DPCM sample would be interfering with the samples we're trying to play (unless you're playing PCM on another channel, somehow).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 48 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group