It is currently Tue Jul 29, 2014 7:37 am



Post new topic Reply to topic  [ 43 posts ]  Go to page 1, 2, 3, 4, 5  Next
Author Message
 Post subject: SD card MOD S3M soundtrack player on PIC32
PostPosted: Sun Nov 20, 2011 5:44 pm 
Offline

Joined: Tue Sep 13, 2011 5:55 am
Posts: 36
Location: Paris
Accurate MOD or S3M player with all Protracker / Scream tracker 3 effects

http://www.youtube.com/watch?v=Gg9AeQXbcFM
My new FAT16/32/SDHC SDcard (FatFs) version :
http://www.youtube.com/watch?v=i3Yl0TISQBE

Can read any .MOD that fit in program memory of Uno32 (128K) or Max32 (512K)

There are thousands of quality music that can be played on this code: http://modarchive.org

46KHz 11 bits with linear interpolation and stereo PWM !!! 100% integer/fixed point DSP algorithm and circular sound buffer / file system buffer.



Source code for MPIDE and MPLAB here -> http://www.serveurperso.com/temp/

Have fun:)

Pascal


Attachments:
MPIDE-Terminal.png
MPIDE-Terminal.png [ 17.48 KiB | Viewed 3310 times ]

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


Last edited by serveurperso on Sat Dec 24, 2011 9:55 pm, edited 37 times in total.
Top
 Profile  
 
 Post subject: Re: Amiga MOD soundtrack file player on PIC32
PostPosted: Mon Nov 21, 2011 4:06 am 
Offline

Joined: Sat Nov 12, 2011 1:31 am
Posts: 4
Nice! I liked your Audio Spectrum Analyser as well.


Top
 Profile  
 
 Post subject: Re: Amiga MOD soundtrack file player on PIC32
PostPosted: Fri Nov 25, 2011 12:15 am 
Offline

Joined: Tue Sep 13, 2011 5:55 am
Posts: 36
Location: Paris
Large code removed (zip)

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


Last edited by serveurperso on Sun Dec 11, 2011 1:23 pm, edited 7 times in total.

Top
 Profile  
 
 Post subject: Re: Amiga MOD soundtrack file player on PIC32
PostPosted: Sun Nov 27, 2011 3:18 pm 
Offline

Joined: Sun Nov 27, 2011 3:08 pm
Posts: 2
Amazing!
I tried to code a mod player on AVR XMEGA few mounths ago, it was pretty difficult especially because i used float algo to have a better sound, which finally doesnt work correctly with all mods.
Can we have a look at your source code? I'm curious to see how you use the PWM as stereo DAC.

EDIT: oh sorry, It's on .pde file... weird extension. :)


Top
 Profile  
 
 Post subject: Re: Amiga MOD soundtrack file player on PIC32
PostPosted: Sun Nov 27, 2011 4:44 pm 
Offline

Joined: Tue Sep 13, 2011 5:55 am
Posts: 36
Location: Paris
Hi, thanks:) you don't need float, fixed point DSP and multiply before divide give very good accuracy and way better performance, If you put a 16 bit DAC on my player you get exactly the sound of any tracker with "linear interpolation" setup. I use 10 bits for mantissa (#define DIVIDER 10)

It use hardware PWM feature of PIC32 :

Code:

Setup :

 // 9 bits stereo PWM
 OpenTimer2(T2_ON | T2_PS_1_1, 512);
 OpenOC1(OC_ON | OC_TIMER2_SRC | OC_PWM_FAULT_PIN_DISABLE, 0, 0);
 OpenOC2(OC_ON | OC_TIMER2_SRC | OC_PWM_FAULT_PIN_DISABLE, 0, 0);

 // Sampler
 ConfigIntTimer3(T3_INT_ON | T3_INT_PRIOR_3);
 OpenTimer3(T3_ON | T3_PS_1_1, F_CPU / SAMPLERATE);


extern "C" {
 void __ISR(_TIMER_3_VECTOR, ipl3) T3InterruptHandler() {
  mT3ClearIntFlag();

 for(..............

..........Mixer code.............

   // Upscale to 9 bits
   out *= 2;

   // Channel volume
   out = out * Sampler.channelVolume[channel] / 64;

   // Channel panning 0 is hard left 128 is hard right
   sumL += out * min(128 - Sampler.channelPan[channel], 64) / 64;
   sumR += out * min(Sampler.channelPan[channel], 64) / 64;
  }

  // Downscale to 9 bits
  sumL /= Mod.numberOfchannels;
  sumR /= Mod.numberOfchannels;

  // Signed to unsigned
  SetDCOC1PWM(sumL + 256);
  SetDCOC2PWM(sumR + 256);
 }
}




Sorry for me english

Pascal

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


Top
 Profile  
 
 Post subject: Re: Amiga MOD soundtrack file player on PIC32
PostPosted: Tue Nov 29, 2011 8:12 am 
Offline

Joined: Tue Nov 29, 2011 5:16 am
Posts: 19
This is brilliant, can't wait to give this a go and add some LCD output for song name, track length, etc. Maybe even an equalizer of sorts. Thanks a million.


Top
 Profile  
 
 Post subject: Re: Amiga MOD soundtrack file player on PIC32
PostPosted: Tue Nov 29, 2011 8:47 am 
Offline

Joined: Tue Sep 13, 2011 5:55 am
Posts: 36
Location: Paris
I just finished the relationship formulas for maximum sound quality on the PIC32 hardware PWM.
BITDEPTH SAMPLERATE (and DIVIDER) are adjustables and the MOD is always played at the right frequency !

Code:
#define BITDEPTH 10      // 10 bits PWM (80MHz / 1024 = 78125Hz)
#define SAMPLERATE 39063 // 78125Hz / 2
#define DIVIDER 10       // Fixed-point mantissa

// Hertz = 7093789 / (amigaPeriod * 2) for PAL
// Hertz = 7159091 / (amigaPeriod * 2) for NTSC
#define AMIGA (7093789 / 2 / SAMPLERATE << DIVIDER)
// Sampler.channelFrequency[channel] = AMIGA / amigaPeriod

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


Top
 Profile  
 
 Post subject: Re: Amiga MOD soundtrack file player on PIC32
PostPosted: Thu Dec 01, 2011 4:20 am 
Offline

Joined: Tue Nov 29, 2011 5:16 am
Posts: 19
What kind of information/data can be extracted from the MOD to be displayed via an LCD?


Top
 Profile  
 
 Post subject: Re: Amiga MOD soundtrack file player on PIC32
PostPosted: Thu Dec 01, 2011 6:51 am 
Offline

Joined: Tue Nov 29, 2011 5:16 am
Posts: 19
I have a Chipkit UNO32 running on Windows 7.

I'm getting the following error when Uploading to the board:

Code:
c:/users/fcusumano/downloads/mpide-0022-windows-20110822/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: address 0xa0004418 of mod32.cpp.elf section `.stack' is not within region `kseg1_data_mem'
c:/users/fcusumano/downloads/mpide-0022-windows-20110822/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: address 0xa0004800 of mod32.cpp.elf section `.ramfunc' is not within region `kseg1_data_mem'
c:/users/fcusumano/downloads/mpide-0022-windows-20110822/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: Not enough space to allocate both stack and heap.  Reduce heap and/or stack size.
c:/users/fcusumano/downloads/mpide-0022-windows-20110822/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: address 0xa0004418 of mod32.cpp.elf section `.stack' is not within region `kseg1_data_mem'
c:/users/fcusumano/downloads/mpide-0022-windows-20110822/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: address 0xa0004800 of mod32.cpp.elf section `.ramfunc' is not within region `kseg1_data_mem'
c:/users/fcusumano/downloads/mpide-0022-windows-20110822/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: Not enough space to allocate both stack and heap.  Reduce heap and/or stack size.
collect2: ld returned 1 exit status


I'm using the
Code:
NTRONIC3.MOD.h
header file.


Top
 Profile  
 
 Post subject: Re: Amiga MOD soundtrack file player on PIC32
PostPosted: Thu Dec 01, 2011 7:55 am 
Offline

Joined: Tue Sep 13, 2011 5:55 am
Posts: 36
Location: Paris
Can you re download the last version ? I tested It work with Mpide 0022 20110822

(Or reduce MAXCHANNELS to 16 on older version)

Pascal

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


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

Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron
Theme designed by stylerbb.net © 2008
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All times are UTC [ DST ]