Dreamcast Media Center

This forum is for discussion pertaining to homebrew and indie software for the Dreamcast, such as homebrew games, emulators/interpreters, and other homebrew software/applications. Porting requests and developmental ideas are not to be made here; you can make those here. If you need any help burning discs for homebrew software, this is the place to ask as well.
Post Reply
User avatar
Neoblast
DC Developer
DC Developer
Posts: 314
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Sat Dec 01, 2007 8:51 am
Has thanked: 3 times
Been thanked: 1 time

Re: Dreamcast Media Center

Post by Neoblast »

No, what I'm talking about has nothing to do with your project, it has to do with dcload and dctool as a link between pc and dc, this is what slows down the connection between the dc and the pc, with too many control functions, and a slow ( way slow ) driver. From a 100mbit connection it's not understandable that you get less than 500KB/s of speed, seriously... that's what I'm talking about...

Didn't anyone notice it is too slow?
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Re: Dreamcast Media Center

Post by Chilly Willy »

I've never gotten it to work for me, so I can't comment on the speed.
User avatar
Neoblast
DC Developer
DC Developer
Posts: 314
Joined: Sat Dec 01, 2007 8:51 am
Has thanked: 3 times
Been thanked: 1 time

Re: Dreamcast Media Center

Post by Neoblast »

Do you have a BBA?
Then it is probably an IP problem. If you just burnt it, it has a default local Ip assigned and it must be specified in the pc program or else it just won't work.

I could help you with that on PM if you want, I think we are getting too far off the topic. Mabye we should start a new one with all this.
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Re: Dreamcast Media Center

Post by Chilly Willy »

Yes, I have the BBA, which works fine from PlanetWeb or with Doom. I have no idea why the loader can't reach the DC it just can't. I suspect it might be something to do with ip tables in linux (I use Xubuntu) that doesn't affect Windows.
User avatar
Neoblast
DC Developer
DC Developer
Posts: 314
Joined: Sat Dec 01, 2007 8:51 am
Has thanked: 3 times
Been thanked: 1 time

Re: Dreamcast Media Center

Post by Neoblast »

The adress hardcoded in dcload for dreamcast has to be the same dctool from linux expects, to make sure, get your dc load cdrom, hex edit the bin and search for 192.168, then edit it to suit your ip, burn again and tell dctool to send whatever you want to send to that IP, that or use ARP with the mac and it should work fine.

Any other thing might be firewall issues...
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has thanked: 0
Been thanked: 5 times

Re: Dreamcast Media Center

Post by PH3NOM »

Chilly Willy wrote:
PH3NOM wrote:Next Ill try out some 96kHz samples to see how the DC's SPU handles it!
Hopefully software re-sampling wouldn't be necessary. But if it is, 48kHz would be the re-sample rate, or should it be 44.1kHz for DC?
Err - from the formula used to set the sample rate, it seems AICA plays at 44.1kHz, and the sample is resampled in hardware to that rate. I have no idea how AICA's resampling would sound for something like that. I guess you'll have to try it and see. 48 to 44.1 shouldn't be a problem.
Cool, I tried some 96kHz MP4's with DCMC last night. It sounds the same as 48kHz!
Chilly Willy wrote:
PH3NOM wrote:And, to be perfectly clear, 6ch audio is down-mixed to stereo ( in software ) before sending the samples to the SPU.
There are a number of different down-mix formulas used by different players to allow simple mixing, or Dolby mixing, Dolby Pro mixing, etc. You'll probably want to check that out... maybe make it an option the user can set.
Yeah, currently LibA52 is using Dolby Pro downmixing, and LibFAAD is using a standard Stereo downmix.
It is a good idea to put the downmixing functions into my audio driver, then it would be easy to allow
the user to change this, in the GUI.
Chilly Willy wrote: I followed this guide:
http://www.dcemu.co.uk/vbulletin/thread ... from-China

If you notice my posts (I'm JLF65 over there), it cost me a total of $26.14 USD and took almost 7 weeks, but I'm happy with how it turned out. I'm using an 8GB MicroSDHC card in the adapter, with no problems so far. I'm currently ripping my Sonic Adventure disc in DreamShell to the SD card. I'll probably rip a number of my game discs to see if they work so I can cut back on wear on the drive. I already made an SDISO for my Doom port... the SD is noticeably slower than the CD drive but I like the lack of grinding on the drive. :mrgreen:
Haha, nice. I have all the parts, I just havn't had time to assemble the adapter, yet.
I need to track down an old friend, to see if he can assemble it for me :o
Stryfe
Psychotic DCEmu
Psychotic DCEmu
Posts: 577
Joined: Mon Aug 11, 2008 9:34 am
Location: Nowhere U.S.A.
Has thanked: 0
Been thanked: 0

Re: Dreamcast Media Center

Post by Stryfe »

Edit;
The SD card options sound nice, but I'll not be able to get one anytime soon.

Will you still be implementing optimizations for non-sd users?
ImageImageImageImage
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Re: Dreamcast Media Center

Post by Chilly Willy »

PH3NOM wrote:
Chilly Willy wrote:
PH3NOM wrote:Next Ill try out some 96kHz samples to see how the DC's SPU handles it!
Hopefully software re-sampling wouldn't be necessary. But if it is, 48kHz would be the re-sample rate, or should it be 44.1kHz for DC?
Err - from the formula used to set the sample rate, it seems AICA plays at 44.1kHz, and the sample is resampled in hardware to that rate. I have no idea how AICA's resampling would sound for something like that. I guess you'll have to try it and see. 48 to 44.1 shouldn't be a problem.
Cool, I tried some 96kHz MP4's with DCMC last night. It sounds the same as 48kHz!
Nice! Good to hear... in more ways than one. :wink: :lol:
Chilly Willy wrote:
PH3NOM wrote:And, to be perfectly clear, 6ch audio is down-mixed to stereo ( in software ) before sending the samples to the SPU.
There are a number of different down-mix formulas used by different players to allow simple mixing, or Dolby mixing, Dolby Pro mixing, etc. You'll probably want to check that out... maybe make it an option the user can set.
Yeah, currently LibA52 is using Dolby Pro downmixing, and LibFAAD is using a standard Stereo downmix.
It is a good idea to put the downmixing functions into my audio driver, then it would be easy to allow
the user to change this, in the GUI.
That would be good - pull all the down-mixing into a single module of the program so it's easier to control. While you're doing that, it gives you the chance to look over all the ways different libs go about doing down-mixing. You may find some do a better job than others.
Chilly Willy wrote: I followed this guide:
http://www.dcemu.co.uk/vbulletin/thread ... from-China

If you notice my posts (I'm JLF65 over there), it cost me a total of $26.14 USD and took almost 7 weeks, but I'm happy with how it turned out. I'm using an 8GB MicroSDHC card in the adapter, with no problems so far. I'm currently ripping my Sonic Adventure disc in DreamShell to the SD card. I'll probably rip a number of my game discs to see if they work so I can cut back on wear on the drive. I already made an SDISO for my Doom port... the SD is noticeably slower than the CD drive but I like the lack of grinding on the drive. :mrgreen:
Haha, nice. I have all the parts, I just havn't had time to assemble the adapter, yet.
I need to track down an old friend, to see if he can assemble it for me :o
Ah, so you want to build it yourself... or have someone else do the grunt work. :grin:

Given the price of a plain USB SD adapter, if you can mod it yourself (or get a friend to), it can save time and money.
User avatar
Neoblast
DC Developer
DC Developer
Posts: 314
Joined: Sat Dec 01, 2007 8:51 am
Has thanked: 3 times
Been thanked: 1 time

Re: Dreamcast Media Center

Post by Neoblast »

Stryfe wrote:Edit;
The SD card options sound nice, but I'll not be able to get one anytime soon.

Will you still be implementing optimizations for non-sd users?
I guess so, what it doesn't have is sd support for now, but phenom is trying to squeeze out the dc potential , specially for the cd.
User avatar
Basil
Insane DCEmu
Insane DCEmu
Posts: 200
Joined: Wed Apr 09, 2008 9:04 am
Has thanked: 13 times
Been thanked: 0
Contact:

Re: Dreamcast Media Center

Post by Basil »

So when the project will be available for testing ?
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has thanked: 0
Been thanked: 5 times

Re: Dreamcast Media Center

Post by PH3NOM »

Basil wrote:So when the project will be available for testing ?
It would be nice to have a public release soon, maybe around 4th of July. But that is far from a promise!
Realistically I would like to be finished with the project by the end of the summer.
Aside from finishing what I want to do with the code, I would also like to make a website to centralize the project before I release anything.

Just rest assured I will be working on this project, as much as I can. There are many things still to solidify.

Currently, I am finishing my re-write of the LibMPG123 decoder to use the k:os sound stream functions.

Trying to use SDL audio while decoding with XviD was stupid slow! :o

I believe my port of LibMPG123 is actually faster than the existing K:OS MP3 port ( the library itself is using SH4-optimized inline ASM for the idct ) but I need to do some benchmarking to provide some numbers to back it up.
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Re: Dreamcast Media Center

Post by Chilly Willy »

SDL in general on the DC isn't very helpful. You're better off just using KOS straight than SDL for either video or audio. There's plenty of example code, and it's easy.
User avatar
Neoblast
DC Developer
DC Developer
Posts: 314
Joined: Sat Dec 01, 2007 8:51 am
Has thanked: 3 times
Been thanked: 1 time

Re: Dreamcast Media Center

Post by Neoblast »

SDl is good for quick ports, and some games but not if you want to squeeze the dc that's for sure. Still I got a decent performance for 2d stuff but video playback is on another league...
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has thanked: 0
Been thanked: 5 times

Re: Dreamcast Media Center

Post by PH3NOM »

Chilly Willy wrote:SDL in general on the DC isn't very helpful. You're better off just using KOS straight than SDL for either video or audio. There's plenty of example code, and it's easy.
For DCMC, all video output is done using the PVR directly.

For audio output, it was really easy to bolt on a SDL audio driver for all of the various audio decoder libraries.

CPU speed using SDL mixer is not a problem for decoding only audio on DC.

But, when simultaneously decoding XviD video and MP3 audio, SDL mixer shows what a burden on CPU it really is.

I have basically finished the <dc/sound/stream.h> implementation of LibMPG123.
It wasnt really necessary to be this complex, but I decided to follow the mold of the K:OS examples

Code: Select all

/*
**
** mpg123spu.c 
** (C) PH3NOM 2011
**
*/

#include <kos/thread.h>
#include <dc/sound/stream.h>

#include <assert.h>
#include <string.h>
#include "stdio.h"
#include "sys/types.h"

#include "mpg123.h"

#include "mpg123spu.h"

#define BS_SIZE 65536
#define BS_MIN  16*1024		

FILE * mp3fd;
mpg123_handle *mh;
char * mp3file[128];

static unsigned int buffer[BS_SIZE], *buf_ptr;
unsigned int outbuf[BS_SIZE+16384], *outbuf_ptr;
static int pcm_count, pcm_discard;
static int err, bs_count, rsize;
unsigned int done;

long rate;
int channels, enc;

static snd_stream_hnd_t stream_hnd = -1;
static volatile int spu_status;
static kthread_t * adec_thread;

/* Exit the audio decoder. This is called from outside the decode thread. */
int libmpg123_quit() {
    spu_status = SPU_STATUS_DONE;
    //thd_wait(adec_thread);
    while( spu_status != SPU_STATUS_NULL )
      thd_sleep(10);

    printf("MPG123 Exited ok\n");
}

/* Exit the audio decoder. */
static int mpg_quit() {

    /* Release the audio decoder */       
    mpg123_close(mh);
    mpg123_exit();
                  
    /* Release the audio driver */
    fs_close(mp3fd);
    //free(outbuf);
    //free(buffer);
    sq_clr( mp3file, sizeof(mp3file));
    sq_clr( buffer, sizeof(buffer));
    sq_clr( outbuf, sizeof(outbuf));
    
    printf("LibMPG123 Decoder Finished.\n");

    return 0;
}

/* Initialize the audio decoder */
static int mp3_init( ) {
   
    int i;
    int err = 0;

    /* Open the MP3 File */
    mp3fd = fs_open( mp3file, O_RDONLY );
    assert( mp3fd!= NULL );

    buf_ptr = buffer;
    outbuf_ptr = outbuf;
    pcm_count = pcm_discard = 0;

    /* Initialize the Decoder */
    mpg123_init();
    mh = mpg123_new(NULL, &err);
    assert(mh != NULL);
   
    /* Open the MP3 context in open_fd mode */
    err = mpg123_open_fd(mh, mp3fd);
    assert(err == MPG123_OK);   

}

/* Check to see if more input data is needed, then do so */
static int mp3_read() {

    /* Get the current bitstream offset */
    off_t mp3pos = mpg123_tell_stream (	mh );
    
    /* If the buffer is below the minimum value, pull in more data */    
    if( bs_count <= BS_MIN || err == MPG123_NEED_MORE ) {

       memcpy(buffer, buf_ptr, bs_count);
    
       long bytes_read = fs_read( mp3fd, buffer+bs_count, BS_SIZE-bs_count );
    
       bs_count+= bytes_read; buf_ptr = buffer;
        
    }

    /* Get the bitstream read size */ 
    int read_size = mpg123_tell_stream ( mh ) - mp3pos;
    
    return read_size;      

}

/* Taken from old K:OS MP3 decoder */
static int pcm_empty(int size) {
	if (pcm_count >= size) {
		/* Shift everything back */
		memcpy(outbuf, outbuf + size, pcm_count - size);

		/* Shift pointers back */
		pcm_count -= size;
		outbuf_ptr = outbuf + pcm_count;
	}

	return 0;
}

/* LibMPG123 Decoder callback */
static int mp3_decode(snd_stream_hnd_t hnd, int size, int * actual) {
       
        /* Update the PCM buffer */
        pcm_empty(pcm_discard);
                       
        /* Read the bitstream */
        rsize = mp3_read();
               
        /* Decode the mpeg data */
        err = mpg123_decode(mh, buf_ptr, rsize, outbuf, size, &done);  
        
        /* Adjust the pointers */
        buf_ptr += rsize; 
        bs_count -= rsize;
        outbuf_ptr += done;
        pcm_count += done;
        pcm_discard = *actual = done;

        /* If this is the first frame, intitialize the output structures */
        if (err == MPG123_NEW_FORMAT ){
            mpg123_getformat(mh, &rate, &channels, &enc);
            printf("MP3 File Info: %iHz, %i channels...\n", rate, channels);
        }
        
        /* Sould we exit? */
        if (err == MPG123_ERR){
            printf("err = %s\n", mpg123_strerror(mh));
            spu_status = SPU_STATUS_DONE;
        }
        
        return outbuf;

}

static int mp3_thread() {

    printf("MP3 Decoder Thread Starting\n");

    if( spu_status != SPU_STATUS_NULL ) {
        printf("SPU ERROR: Already Running!\n");
        return -1;
    }

    while( spu_status != SPU_STATUS_DONE) {
        
    switch( spu_status ) {
         
      case SPU_STATUS_NULL:
         mp3_init();   
	     if( err == MPG123_OK ) {
	        stream_hnd = snd_stream_alloc(NULL, SND_STREAM_BUFFER_MAX);
 	        assert( stream_hnd != -1 );
            spu_status = SPU_STATUS_INITIALIZED;
         }
         break;
      case SPU_STATUS_INITIALIZED: 
         snd_stream_set_callback(stream_hnd, mp3_decode); 
         snd_stream_prefill( stream_hnd );
         if( spu_status != SPU_STATUS_DONE )
            spu_status = SPU_STATUS_READY;
         break;
      case SPU_STATUS_READY:   
         snd_stream_start(stream_hnd, rate, channels - 1);
         spu_status = SPU_STATUS_STREAMING;
         break;
      case SPU_STATUS_STREAMING:                    
         while( spu_status != SPU_STATUS_DONE ){ 
            if (snd_stream_poll(stream_hnd) < 0)
               printf("Nothing decoded\n");
            else
               thd_sleep(50); 
         }
         printf("SPU_STATUS: Finish Decode\n");
         break;
      case SPU_STATUS_DONE:
         printf("Shutting Down LibMPG123 and soundstream\n");   
         mpg_quit();
         snd_stream_stop(stream_hnd);
	     snd_stream_destroy(stream_hnd);
	     break;
      
      default:
         mpg_quit();
         snd_stream_stop(stream_hnd);
	     snd_stream_destroy(stream_hnd);
	     break;   
    }
    
    }         

    spu_status = SPU_STATUS_NULL;
    printf("MP3 Decoder Thread Finished\n");
    
    return 0;
}

/* Create a new thread to decode the MP3 File */
void libmpg123_dec( char * mp3_file ) {
    
    sprintf( mp3file, "%s", mp3_file ); 
    adec_thread = thd_create( mp3_thread, NULL);

}
I will post this new K:OS mp3 decoder before I actually release DCMC ;-)
User avatar
Neoblast
DC Developer
DC Developer
Posts: 314
Joined: Sat Dec 01, 2007 8:51 am
Has thanked: 3 times
Been thanked: 1 time

Re: Dreamcast Media Center

Post by Neoblast »

Awesome, that might actually give the chance to use mp3 in 2d games without affecting the performance that much... I've had to use formats like wav or mod, s3m, etc...

DCMC is looking really good so far.
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Re: Dreamcast Media Center

Post by Chilly Willy »

Is that being done on the ARM processor? We need more sound code on the ARM... ogg-vorbis, mp3, and mikmod/modplug at the very least. That would do games and media players the best good.
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has thanked: 0
Been thanked: 5 times

Re: Dreamcast Media Center

Post by PH3NOM »

Chilly Willy wrote:Is that being done on the ARM processor? We need more sound code on the ARM... ogg-vorbis, mp3, and mikmod/modplug at the very least. That would do games and media players the best good.
Well, the sound driver runs on the ARM, and tells the SH4 when it needs some more data.
SH4 is doing all of the decoding, but the library is using SH4-optimized inline ASM for the idct functions.

I originally wanted to have the MP3 decoder running completely on the ARM processor.
https://datatype.helixcommunity.org/Mp3dec

But, the ARM processor on the DC does not have Multiplier logic, so it is almost useless.

MultiMedia Mike mentioned something to me about offloading later stages of decoding onto the ARM, but I havnt heard back from him in a while, so I dont know what exactly he had in mind.
Ayla
DC Developer
DC Developer
Posts: 142
Joined: Thu Apr 03, 2008 7:01 am
Has thanked: 0
Been thanked: 4 times
Contact:

Re: Dreamcast Media Center

Post by Ayla »

You won't be able to do anything on the ARM. It's virtually a ~3MHz chip.
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Re: Dreamcast Media Center

Post by Chilly Willy »

Looking at this thread: viewtopic.php?p=241423

There's some disagreement over the ARM... some old AICA docs from people like the Hitmen suggest it's only up to 25MHz, not 45MHz. The older ARM7 (v3 arch) only clocked up to 26MHz and didn't have multiply instructions. However, EVERYTHING else everywhere says it's a 45MHz ARM7, and an ARM7 that speed would have the multiply instructions. KOS sets the default flag for the compiler to

Code: Select all

	export DC_ARM_CFLAGS="-mcpu=arm7 -Wall -O2 -fno-strict-aliasing"
In any case, a 25MHz ARM v3 without multiply would easily handle tracker music, but probably not anything more involved.
Ayla
DC Developer
DC Developer
Posts: 142
Joined: Thu Apr 03, 2008 7:01 am
Has thanked: 0
Been thanked: 4 times
Contact:

Re: Dreamcast Media Center

Post by Ayla »

The AICA master clock is 45MHz, so the internal hardware (mixer, DSP...) is running at 45MHz.
However, the ARM has its own clock of 22,5MHz. But because of lack of cache, the ARM won't be able to provide more than ~3 MIPS.

Furthermore, it's an ARM7DI; while it has the mul opcodes, those take a lot of cycles to be executed, compared to GBA's ARM7TDMI for instance (I remember calculating it for a 32b,32b=>64b multiplication, it was something like 8 times slower).
Post Reply