SD card MOD S3M soundtrack player on PIC32

Show off your projects to others!
serveurperso
Posts: 36
Joined: Tue Sep 13, 2011 5:55 am
Location: Paris
Contact:

Re: MOD/S3M soundtrack player on PIC32

Post by serveurperso » Sat Dec 24, 2011 9:39 pm

Code: Select all

//#define SYSCLK 80000000L
#define SYSCLK 96000000L

#define BITDEPTH 11                           // 11 bits PWM
#define SAMPLERATE (SYSCLK / (1 << BITDEPTH)) // 96MHz / (1 << 11) = 46875Hz
#define SOUNDBUFFERSIZE 8192                  // Circular sound buffer
#define FATBUFFERSIZE 4096                    // File system buffers
#define DIVIDER 10                            // Fixed-point mantissa
For Protracker :

Code: Select all

// Hz = 7093789 / (amigaPeriod * 2) for PAL
// Hz = 7159091 / (amigaPeriod * 2) for NTSC
#define AMIGA (7093789 / 2 / SAMPLERATE << DIVIDER)
// Mixer.channelFrequency[channel] = AMIGA / amigaPeriod
For Scream tracker 3 :

Code: Select all

// Hz = 14317056 / amigaPeriod
#define AMIGA (14317056 / SAMPLERATE << DIVIDER)
// Mixer.channelFrequency[channel] = AMIGA / amigaPeriod
Note the << DIVIDER (multiplier)

And inside my mixing routine Mixer.channelSampleOffset run very fast :

Code: Select all

Mixer.channelSampleOffset[channel] += Mixer.channelFrequency[channel];
But reals sample pointers are >> DIVIDED

Code: Select all

samplePointer = Mixer.sampleBegin[Mixer.channelSampleNumber[channel]] +
                (Mixer.channelSampleOffset[channel] >> DIVIDER);
A sample reLoop is not a MODULO %, is just :

Code: Select all

Mixer.channelSampleOffset[channel] -= Mixer.sampleLoopLength[Mixer.channelSampleNumber[channel]] << DIVIDER;
Just need One euclidian div instruction by note (you can get some high speed assembly code on the web?)

this same DIVIDER is used for Linear interpolation :

Code: Select all

out += (next - current) * (Mixer.channelSampleOffset[channel] & (1 << DIVIDER) - 1) >> DIVIDER; 
!!!!!!!!!!!!!! look the compiled code you can't do faster :D ((1 << DIVIDER) - 1) as you know is not in the binary code)

Pascal
(French user) English is not my native language, please forgive my mistakes.

slayer1991
Posts: 73
Joined: Sun Nov 27, 2011 5:11 am

Re: SD card MOD S3M soundtrack player on PIC32

Post by slayer1991 » Thu Jan 19, 2012 8:02 pm

So can you read/write using MPIDE on FAT16?

serveurperso
Posts: 36
Joined: Tue Sep 13, 2011 5:55 am
Location: Paris
Contact:

Re: SD card MOD S3M soundtrack player on PIC32

Post by serveurperso » Thu Feb 09, 2012 3:24 pm

slayer1991 wrote:So can you read/write using MPIDE on FAT16?
You need to rework a fatfs wrapper for MPIDE... It's not very complicated because the bulk of the work is already done by Aiden Morrison and Riccardo Leonardi inside mmcPIC32.c (PIC32MX512 SPI module for the generic fatfs lib)

Pascal
(French user) English is not my native language, please forgive my mistakes.

dosikus
Posts: 1
Joined: Tue Feb 09, 2016 12:35 pm

Re: SD card MOD S3M soundtrack player on PIC32

Post by dosikus » Tue Feb 09, 2016 12:43 pm

The link http://www.serveurperso.com/temp/ is empty .
Put please sources.

3dtech
Posts: 1
Joined: Mon Mar 27, 2017 12:31 pm
Contact:

Re: SD card MOD S3M soundtrack player on PIC32

Post by 3dtech » Mon Mar 27, 2017 12:38 pm

I really enjoy working with your Basic ProtoShields. It is a means to make prototype creations (add-ons) usuable between a variety of the development boards I work with.

Post Reply