Making noise with the SPC700 , help!

Discussion of hardware and software development for Super NES and Super Famicom.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Post Reply
kp64
Posts: 31
Joined: Fri Aug 01, 2014 3:13 pm

Making noise with the SPC700 , help!

Post by kp64 »

I have zero knowledge about digital audio.
I started playing with the SPC700 and I want to reproduce one sample.
Im using the "cymbal.brr" sample that 93143 posted here:(basamples_v2.7z)
viewtopic.php?f=12&t=10696&start=120#p142336

The situation is the following:

-I have written one 65816 routine that can upload data to the APU RAM and set the execution address
-I can transfer the sample and the program.(The SPC700 executes my program without problem)
-The sample and the program are stored in the ROM like a single binary file , organized in this way:

Code: Select all

$0000->|--------------| \
       | SAMPLE       | | "cymbal.brr" 17010 bytes
$4272->|--------------| /
       | Program      |
$43B6->|--------------|
This binary is transfered to $0200-$45B6 on the APU RAM.

This is my SPC700 code:
(I'm unexperienced with the spc700 , I dont know the instructions & addressing modes , so be kind and dont laught too much :oops: )

Code: Select all

;-----------------------------------------------------------------------------------------
;*This WLA directives are from the nwarp code by d4s
;-----------------------------------------------------------------------------------------
.MEMORYMAP					; Tell WLA that the SPC has RAM at locations ;$0000-$ffff in every bank
	SLOTSIZE $10000			; and that this area is $10000 bytes in size.
	DEFAULTSLOT 0			; There is only a single slot in SNES, other consoles
	SLOT 0 $0000				; may have more slots per bank.
.ENDME

.ROMBANKSIZE $00144		; Every ROM bank is 64 KBytes in size
.ROMBANKS 1
;----------------------------------------------------------------------------------------

.EQU DIR $02	;SOUND DIRECTORY ADDRESS

.BANK 0 SLOT 0

	mov A,#$5D
	mov $F2,A

	mov A,#DIR
	mov $F3,A	;Set DIR value ( 2 * 100h = 200h)

	;Set volume to the max

	mov A,#$0C
	mov $F2,A

	mov A,#$7F
	mov $F3,A	;Left output main volume

	mov A,#$1C
	mov $F2,A

	mov A,#$7F
	mov $F3,A	;Right Output main volume

	;VOICE 0 SETTING

	mov A,#$00
	mov $F2,A

	mov A,#$7F
	mov $F3,A	;voice 0 volume left

	mov A,#$01
	mov $F2,A

	mov A,#$7F
	mov $F3,A	;voice 0 volume RIGHT

	mov A,#$02
	mov $F2,A

	mov A,#$00
	mov $F3,A	;voice 0 pitch low byte

	mov A,#$03
	mov $F2,A

	mov A,#$10
	mov $F3,A	;voice 0 pitch high byte

	 mov A,#$04
	mov $F2,A

	mov A,#$00
	mov $F3,A	;voice 0 SRCN

	;============;

	mov A,#$4C
	mov $F2,A

	mov A, #$01
	mov $F3,A	;K-ON , activate voice 0

-:
	;instructions for testing
	mov A,#$DD
	mov X,#$EE
	mov Y,#$FF

	bra -
What im doing wrong?
Any example of how to do this?
Any brr test sample?
kp64
Posts: 31
Joined: Fri Aug 01, 2014 3:13 pm

Re: Making noise with the SPC700 , help!

Post by kp64 »

I tried again:

Code: Select all

;-----------------------------------------------------------------------------------------
.MEMORYMAP					; Tell WLA that the SPC has RAM at locations ;$0000-$ffff in every bank
	SLOTSIZE $10000			; and that this area is $10000 bytes in size.
	DEFAULTSLOT 0				; There is only a single slot in SNES, other consoles
	SLOT 0 $0000				; may have more slots per bank.
.ENDME

.ROMBANKSIZE $00144		; Every ROM bank is 64 KBytes in size
.ROMBANKS 1
;----------------------------------------------------------------------------------------


.EQU DIR $02	;SOUND DIRECTORY ADDRESS

.BANK 0 SLOT 0

	mov $F2,#$5D
	mov $F3,#DIR	;Set DIR value ( 2 * 100h = 200h)

	;Set volume to the max

	mov $F2,#$0C
	mov $F3,#$7F	;Left output main volume

	mov $F2,#$1C
	mov $F3,#$7F	;Right Output main volume


	mov $f2,#$0F
	mov $F3,#$7F	;FIR filter


	mov $f2,#$0D
	mov $f3,#$00	;Echo feedback = 0

	mov $f2,#$7D
	mov $f3,#$00	;ESA , shortest echo delay

	;VOICE 0 SETTING

	mov $f2,#$2C
	mov $f3,#$00	;Left echo volume = 0


	mov $f2,#$3C
	mov $f3,#$00	;Right echo volume = 0


	mov $F2,#$00
	mov $F3,#$7F	;voice 0 volume left


	mov $F2,#$01
	mov $F3,#$7F	;voice 0 volume RIGHT


	mov $F2,#$02
	mov $F3,#$00	;voice 0 pitch low byte

	mov $F2,#$03
	mov $F3,#$10	;voice 0 pitch high byte


	mov $F2,#$04
	mov $F3,#$00	;voice 0 SRCN


	mov $F2,#$07
	mov $F3,#$7F	;Gain up

	;============;

	mov $F2,#$4C
	mov $F3,#$01	;K-ON , activate voice 0

-:
	;instructions for testing
	mov A,#$DD
	mov X,#$EE
	mov Y,#$FF

	bra -
still not working :x
nocash
Posts: 1405
Joined: Fri Feb 24, 2012 12:09 pm
Contact:

Re: Making noise with the SPC700 , help!

Post by nocash »

If you want to hear something then you will need to unmute the "FLG" register (DSP register 6Ch).

Your memory map could be improved, too. If the program starts at 4272h in SNES ROM, and gets moved to an address 200h bytes higher in APU RAM, then your program should start at 4472h. So you should tell the assembler that is originated at that address (by some directive like "ORG 4472h").
At the moment that shouldn't matter though since your code isn't using any address operands (apart from the BRA opcode; which works regardless of the origin, since it's a relative jump).
Might be also good to place the code at 0200h, and the data at, say, 1000h and up. So you won't need to change the code ORG setting each time when the size of your sample data changes.
kp64
Posts: 31
Joined: Fri Aug 01, 2014 3:13 pm

Re: Making noise with the SPC700 , help!

Post by kp64 »

nocash wrote:If you want to hear something then you will need to unmute the "FLG" register (DSP register 6Ch).
With $6C set at $00 and GAIN(Voice 0) set to $7F , a whistle sounds each time that I start the program,
and If I activate all the chanels , I get a lot of random noise , at least thats something :P .
nocash wrote: Your memory map could be improved, too. If the program starts at 4272h in SNES ROM, and gets moved to an address 200h bytes higher in APU RAM, then your program should start at 4472h. So you should tell the assembler that is originated at that address (by some directive like "ORG 4472h").
At the moment that shouldn't matter though since your code isn't using any address operands (apart from the BRA opcode; which works regardless of the origin, since it's a relative jump).
Might be also good to place the code at 0200h, and the data at, say, 1000h and up. So you won't need to change the code ORG setting each time when the size of your sample data changes.
I will do that , thanks.
93143
Posts: 1371
Joined: Fri Jul 04, 2014 9:31 pm

Re: Making noise with the SPC700 , help!

Post by 93143 »

kp64 wrote:With $6C set at $00 and GAIN(Voice 0) set to $7F , a whistle sounds each time that I start the program,
and If I activate all the chanels , I get a lot of random noise , at least thats something :P .
That sample is a crash cymbal highpassed at 8 kHz, with the tail stretched and looped. The sustained portion is basically a hiss, plus some broadband noise due to the BRR compression. The way you describe it, it sounds like it might be working.

...I should really do something about that thing. It's way longer than it needs to be, and you can hear the loop...

EDIT: Wow, this is harder than it looks. I managed to cut the sample down to less than half its original length with a nearly perfect-sounding short loop, and then the trip through the BRR encoder ruined it. The recovered signal is still smooth to my ears, but the loop is clearly audible in the compression artifacting...

EDIT2: new file, slightly shorter cymbal.brr.
User avatar
bazz
Posts: 476
Joined: Fri Sep 02, 2011 8:34 pm
Contact:

Re: Making noise with the SPC700 , help!

Post by bazz »

seeing this poor fella trying to get his program work makes me want to write up a tutorial
Post Reply