Home
JAQForum Ver 19.10.27
Log In or Join  
Active Topics
Local Time 09:18 20 Nov 2019 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Micromite eXtreme: HD Audio - PLAY FLAC

     Page 1 of 2    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 2964
Posted: 04:56am 03 Mar 2017
Copy link to clipboard 



Release 5.3.10 for the 64, 100 and 144-pin MZs now supports FLAC playback over I2S

Supported frequencies are:

44100Hz 16-bit(CD quality) and 24-bit
48000Hz 16-bit and 24-bit
88200Hz 16-bit and 24-bit
96000Hz 24-bit
192000Hz 24-bit (252MHz only)

I2S Dacs are cheap and readily available. In the picture I'm using this one

Other versions include this and this

The command syntax is simplicity itself

PLAY FLAC "flacfilename" [,interruptwhenfinished]

so exactly the same as "PLAY WAV". The command is non-blocking and

PLAY PAUSE, PLAY RESUME, and PLAY STOP work as expected

Volume control is not available on FLAC files. With high definition audio volume should really only be controlled at the analogue stage.

Connections to the DAC are as follows:

MCLK - SPI3-IN (this is re-configured as an output of the clock signal and runs at 128 to 512 times the frame clock depending on the frequency allowing the DAC to oversample.
DATA - SPI3-OUT
SCK (Bit-Clock) - SPI3-CLK
LRCK (Frame-Clock) - pin-97 on the 144-pin, pin 68 on the 100-pin

All these pins are available on the SPI3 header on the Backpack144

Connections for the 64-pin chip are as follows:

MCLK - Pin-13
DATA - Pin-45
LRCK - Pin-30
SCK - Pin-29

For DACs with an inbuilt MCLK this connection can be omitted.

The functionality on the 64-pin chip would allow a very nice HD-audio touchscreen MMX-pod to be built

For anyone not familiar with the FLAC music format see wikipedia. FLAC is MP3 done properly

The FLAC codec was ported from the work of David Reid to whom great thanks are due Edited by matherp 2017-03-04
 
plasma
Guru

Joined: 08/04/2012
Location: Germany
Posts: 437
Posted: 11:25am 03 Mar 2017
Copy link to clipboard 

great Matherp, thx a lot.

is it possible to get support for mp3 and wav even over i2s , to get only one audio way?
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 2964
Posted: 12:37pm 03 Mar 2017
Copy link to clipboard 

  Quote  is it possible to get support for mp3 and wav even over i2s , to get only one audio way?


mp3 no: too much code and tables to support all the variants
wav: doable but why? easy to convert to flac which is also lossless on the source device
 
Zonker

Guru

Joined: 18/08/2012
Location: United States
Posts: 708
Posted: 05:00pm 03 Mar 2017
Copy link to clipboard 

Wow..! I didn't know you could put that kind of stream rate down the I2C hole..!
So, we can not write a player "front end" for this.. (sweet)..
 
Grogster

Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 6925
Posted: 05:22pm 03 Mar 2017
Copy link to clipboard 

Wow......

That is awesome - I will HAVE to play with that. Pun intended.

[Quote=matherp]For anyone not familiar with the FLAC music format see wikipedia. FLAC is MP3 done properly[/Quote]

LOL!

Dammit.
Does that mean I have to re-encode all my CD's to FLAC?!

Joking aside, that is probably not a BAD idea, frankly.
They are all mostly as 128kb MP3, which is lossy as hell with the HF.
As I understand it, even 320kb MP3 is still not totally lossless as FLAC is, so perhaps now is the time to re-encode my entire library.....
Smoke makes things work. When the smoke gets out, it stops!
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 986
Posted: 08:17pm 03 Mar 2017
Copy link to clipboard 

  Grogster said  
... so perhaps now is the time to re-encode my entire library.

that really won't be as much fun as it sounds... I did this a couple of years ago... thinking "yeah that'll be great to go through all my old stuff again"

It gets old really quickly

Got about a third in and still needs finishing
Edited by CaptainBoing 2017-03-05
 
Grogster

Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 6925
Posted: 09:36pm 03 Mar 2017
Copy link to clipboard 

Heh, heh!

Yeah, I hear that.

I have a few hundred CD's, so it probably would get old very quickly as you say.
Smoke makes things work. When the smoke gets out, it stops!
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2215
Posted: 10:06pm 03 Mar 2017
Copy link to clipboard 

GDay Zonker,

  Zonker said   Wow..! I didn't know you could put that kind of stream rate down the I2C hole..!


It is actually I2S not I2C.. Yeah I had to look it up as well

Details of I2C and I2S HERE!!

@Peter,
Fantastic work... Do you not ever sleep?

Regards,

Mick
Mick's uMite Stuff can be found HERE

 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 2964
Posted: 11:19pm 03 Mar 2017
Copy link to clipboard 

  Quote  Does that mean I have to re-encode all my CD's to FLAC?!


FLAC or ALAC : that way you are future proof. I hate mp3 with a passion: invented by computer scientists who clearly don't understand music.

Couple of notes on the DAC I'm using pictured above.
On mine the red and black wires on the power connector were reversed, the silk-screening is correct.
The DAC has a 50MHz oscillator for MCLK connected via a 100R resistor next to the oscillator. I removed the resistor to use my MMX generated clock. I haven't tested with the on-board oscillator. It seems more sensible to have all three clocks fully synchronous.
The sound quality though my good amp/speakers is outstanding - certainly better than playing from the source CD with my CD player. All of the clock generation in the MMX is done in hardware directly from the 24MHz oscillator and looks totally jitter free on the scope. I personally can't hear a difference between 96KHz and 192KHz but that may be because of the sample FLAC files I've found on the web and downloaded.Edited by matherp 2017-03-05
 
Zonker

Guru

Joined: 18/08/2012
Location: United States
Posts: 708
Posted: 04:28am 04 Mar 2017
Copy link to clipboard 

Oh.. Thanks, Mick..

I thought it was a typo..!!

Very interesting... As usual, my ignorance is showing..

Awesome work Gent's..! I love this stuff..
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2745
Posted: 02:24am 06 Mar 2017
Copy link to clipboard 

Just got this working through a Raspberry Pi DAC and it sounds AMAZING.

Now to convert my entire collection from Apple lossless . . . . .

@Peter - three things

1> With the FAT_FS, what is the maximum capacity uSD that should work? I need maximum storage space for FLAC files

2> I have noticed that after the FLAC plays, the MMX hangs. And possibly this is linked: the file seems to stop part way through (hung). Reset works fine but not had a file completely play 'successfully' without hanging.

Have tried sound files lasting several minutes rather than just a few seconds - so this may be the reason? Also typing: PLAY FLAC "filename i.e. with no closing bracket or interrupt 'sub'

3> When the PLAY FLAC command is issued, it returns some 'feedback' regarding the file - can this be switched off (optionally?)

WW

EDIT: On MMX144 @ 252MHz, v5.03.11
EDIT2: No MCLK. 192KHz, 88KHz, and 48KHz all 24bitEdited by WhiteWizzard 2017-03-07
For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.org
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 2964
Posted: 02:35am 06 Mar 2017
Copy link to clipboard 

  Quote  With the FAT_FS, what is the maximum capacity uSD that should work? I need maximum storage space for FLAC file


In theory FatFs can go above 32Gb using exFat but I haven't got a card > 16Gb so this is untested.

  Quote  I have noticed that after the FLAC plays, the MMX hangs. And possibly this is linked: the file seems to stop part way through (hung). Reset works fine but not had a file completely play 'successfully' without hanging.


This sounds like another WW funny. It works perfectly for me playing long files. There is an errata on using the reference oscillator in the MZ in the way I do but I haven't seen any affect of this. I'll post an update that uses the recommended workround for the errata. Make sure you are using a reasonably fast SDcard.

  Quote  When the PLAY FLAC command is issued, it returns some 'feedback' regarding the file - can this be switched off (optionally?)


I'll remove this in the update
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2745
Posted: 03:07am 06 Mar 2017
Copy link to clipboard 

  matherp said  
  Quote  his sounds like another WW funny.


Thats what happens when I stress test!

Another issue:

Clear a MMX so no program in memory
Enter (and save) a one line program: A$=input
At command prompt type PLAY FLAC "filename (reports back file parameters)
now type RUN

You get an: Error: The file/directory object is invalid

Can I propose that typing RUN (or EDIT?) stops the FLAC cleanly.

You may think of a better way - but I am just advising for a more 'friendly' outcome

WW

For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.org
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2745
Posted: 03:17am 06 Mar 2017
Copy link to clipboard 

  matherp said   Make sure you are using a reasonably fast SDcard.


Tried a different SD card and now works fine Thanks for that pointer!
For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.org
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 2964
Posted: 03:58am 06 Mar 2017
Copy link to clipboard 

Here is the simplest multi-file player program

Chdir "A:/flac" 'go to wherever the flac files are saved
a$=Dir$("*.flac",file)
Do While a$<>""
i=0
Print "Now playing ",a$
Play flac a$,myint
Do
Loop Until i=1
a$=Dir$()
Loop
'
Sub myint
i=1
End Sub


Note: to avoid any noise from the DAC whilst not playing add a pull up resistor to the MCLK line (22K should be fine)Edited by matherp 2017-03-07
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2745
Posted: 05:42am 06 Mar 2017
Copy link to clipboard 

Plays first track (3 are in the folder), and at the end of it (or start of second?) the MMX resets itself and gives:

CPU exception #0 at address 0xEE49790



For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.org
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 2964
Posted: 06:12am 06 Mar 2017
Copy link to clipboard 

Have you upgraded to v12?

Will it play each file individually or is there a strange filename?

What options are set?Edited by matherp 2017-03-07
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2745
Posted: 06:15am 06 Mar 2017
Copy link to clipboard 

On v12 on a MMX144 at 252MHz.

Folder name is FLACs
Files are Flac1, Flac2, and Flac3 (great imagination I applied there!)

I was just about to have a play to see if I could see if it is the start of the second track causing the issue, or the end of the first.




For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.org
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 2964
Posted: 07:06am 06 Mar 2017
Copy link to clipboard 

I've just run the program on 5 different PCBs covering 64-pin EFH, 64-pin EFG, 100-pin EFH and 144-pin EFH and it works on all of them reading files that cover all variants of FLAC 44.1K, 48K, 88.2K, 96K, 192K, 16 and 24-bit so it must be something about your environment, sdcard or files.

It even plays properly with VGA console output which amazes me as you have then 5 SPI channels at full tilt with DMA and multiple interrupts all going on at once. There is some flicker on the VGA - hardly surprising though Edited by matherp 2017-03-07
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2745
Posted: 07:47am 06 Mar 2017
Copy link to clipboard 

If I CHDIR to FLACs then type FILES I see my three flac files listed.

However, in your code, the line a$=DIR$() returns ._Flac1.flac

If you type PLAY FLAC "._Flac1.flac" you get a reboot and CPU exception error (with a different hex number).


For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.org
 
     Page 1 of 2    
© JAQ Software 2019