You are not logged in.

#1 2010-10-10 07:24:59

panox
Member

About GRRMOD

Hello, i was looking for the way to play mp3 files, and i found the GRRMOD in Google Code, i have downloaded the source code of the sample, and i compiled it, when i ran it in the wii, it seems that works fine, but i didn't played the mp3 file (only the .it, .xm, .x3m, and .mod files), then i look the code of the GRRMOD and i found the file "GRRMOD_MP3.c" there are a lot of functions that seems to be for mp3 playing, so i replaced those functions in the sample code but it still don't play the mp3 file.
i don't know if this is functional, because i just found it in branches section but there is no official publication and/or information about it.
Thanks a lot.

This is the code:

Code:

/*===========================================
        GRRMOD
        - Test Code -
============================================*/
#include <grrlib.h>
#include "grrmod.h"
#include "GRRMOD_internals.h"

#include <stdlib.h>
#include <wiiuse/wpad.h>

// Image file
#include "Impact_9_png.h"

// Mod file
#include "music_mp3.h"
#include "music_mod.h"
#include "music_xm.h"
#include "music_s3m.h"
#include "music_it.h"

#define MAX_WIDTH 6.0f
#define MIN_WIDTH 0.2f
#define DECAY 0.5f;

typedef struct
{
    u8 *Mem;
    u32 Size;
} PLAYLIST;

typedef struct
{
    int freq;
    int vol;
    int realvol;
    float width;
} CH;

static CH channel1 = {0, 0, 0, MIN_WIDTH};
static CH channel2 = {0, 0, 0, MIN_WIDTH};
static CH channel3 = {0, 0, 0, MIN_WIDTH};
static CH channel4 = {0, 0, 0, MIN_WIDTH};
static float calc_size(u8 voice, CH* channel);


int main(int argc, char **argv) {
    float a = 0.0f;
    u8 Volume = 64;
    s8 SongNum = 0;
    PLAYLIST PlayList[] = { {(u8 *)music_mp3, music_mp3_size},
                            {(u8 *)music_mod, music_mod_size},
                            {(u8 *)music_s3m, music_s3m_size},
                            {(u8 *)music_it, music_it_size},
                            {(u8 *)music_xm, music_xm_size} };

    GRRLIB_Init();
    GRRLIB_texImg *tex_Font = GRRLIB_LoadTexture(Impact_9_png);
    GRRLIB_InitTileSet(tex_Font, 10, 16, 32);

    GRRMOD_MP3_Init();

    GRRMOD_MP3_SetMOD(PlayList[0].Mem, PlayList[0].Size);
    GRRMOD_MP3_SetVolume(64);
    WPAD_Init();
    PAD_Init();
    GRRLIB_Settings.antialias = true;
    GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);

    // Loop forever
    while(1) {
        WPAD_ScanPads();
        PAD_ScanPads();         // Scan the Wiimotes

        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME || PAD_ButtonsDown(0) & PAD_BUTTON_START) {
            break;
        }
        if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_PLUS ) {
            GRRMOD_MP3_SetVolume(++Volume);
        }
        if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_MINUS) {
            GRRMOD_MP3_SetVolume(--Volume);
        }
        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_A || PAD_ButtonsDown(0) & PAD_BUTTON_A) {
            GRRMOD_MP3_Pause();
        }
        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_1 || PAD_ButtonsDown(0) & PAD_BUTTON_X) {
            GRRMOD_MP3_Start();
        }
        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_2 || PAD_ButtonsDown(0) & PAD_BUTTON_Y) {
           GRRMOD_MP3_Stop();
        }
        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_LEFT || PAD_ButtonsDown(0) & PAD_BUTTON_LEFT) {
            SongNum--;
            if(SongNum < 0) SongNum = 0;
            GRRMOD_MP3_Unload();
           GRRMOD_MP3_SetMOD(PlayList[SongNum].Mem, PlayList[SongNum].Size);
            GRRMOD_MP3_Start();
        }
        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_RIGHT || PAD_ButtonsDown(0) & PAD_BUTTON_RIGHT) {
            SongNum++;
            if(SongNum > 4) SongNum = 4;
            GRRMOD_MP3_Unload();
           GRRMOD_MP3_SetMOD(PlayList[SongNum].Mem, PlayList[SongNum].Size);
            GRRMOD_MP3_Start();;
        }

        GRRLIB_Camera3dSettings(0.0f, 0.0f,13.0f, 0,1,0, 0,0,0);

        GRRLIB_SetLightAmbient(0x333333FF);
        GRRLIB_SetLightDiff(0,(guVector){0.0f,0.0f,0.0f},20.0f,1.0f,0x00FFFFFF);
        GRRLIB_SetLightDiff(1,(guVector){0.0f,13.0f,3.0f},20.0f,1.0f,0x0000FFFF);
        GRRLIB_SetLightDiff(2,(guVector){0.0f,-13.0f,3.0f},20.0f,1.0f,0x00FFFFFF);
        GRRLIB_SetLightDiff(3,(guVector){13.0f,0.0f,3.0f},20.0f,1.0f,0x0000FFFF);
        GRRLIB_SetLightDiff(4,(guVector){-13.0f,0.0f,3.0f},20.0f,1.0f,0x00FFFFFF);

        GRRLIB_3dMode(0.1,1000,45,0,1);

        GRRLIB_ObjectViewInv(-3.0f, 0.0f, 0.0f, a,a*2,a*3, 1.0f,calc_size(0, &channel1),1.0f);
        GRRLIB_DrawCube(1.0,true,0xFFFFFFFF);

        GRRLIB_ObjectViewInv(-1.0f, 0.0f, 0.0f, a,a*2,a*3, 1.0f,calc_size(1, &channel2),1.0f);
        GRRLIB_DrawCube(1.0,true,0xFFFFFFFF);

        GRRLIB_ObjectViewInv(1.0f, 0.0f, 0.0f, a,a*2,a*3, 1.0f,calc_size(2, &channel3),1.0f);
        GRRLIB_DrawCube(1.0,true,0xFFFFFFFF);

        GRRLIB_ObjectViewInv(3.0f, 0.0f, 0.0f, a,a*2,a*3, 1.0f,calc_size(3, &channel4),1.0f);
        GRRLIB_DrawCube(1.0,true,0xFFFFFFFF);


        a+=0.5f;
        GRRLIB_2dMode();
        GRRLIB_Printf(30, 30, tex_Font, 0xFFFFFFFF, 2, "Song: %s", GRRMOD_MP3_GetSongTitle());
        GRRLIB_Printf(30, 60, tex_Font, 0xFFFFFFFF, 2, "Type: %s", GRRMOD_MP3_GetModType());
        GRRLIB_Printf(30, 90, tex_Font, 0xFFFFFFFF, 2, "1/X = Play; 2/Y = Stop; A = Pause; Left = Prev; Right = Next");

        GRRLIB_Render();  // Render the frame buffer to the TV
    }

    GRRMOD_End();
    GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB

    exit(0);  // Use exit() to exit a program, do not use 'return' from main()
}

static float calc_size(u8 voice, CH* channel) {
    int freq = GRRMOD_MP3_GetVoiceFrequency(voice);
    int vol = GRRMOD_MP3_GetVoiceVolume(voice);
    int realvol = GRRMOD_MP3_GetRealVoiceVolume(voice);

    if (freq != channel->freq || vol != channel->vol || realvol > channel->realvol)
    {
        channel->width = MAX_WIDTH;
    }
    else
    {
        channel->width -= DECAY;
        if (channel->width < MIN_WIDTH)
            channel->width = MIN_WIDTH;
    }

    channel->vol = vol;
    channel->freq = freq;
    channel->realvol = realvol;

    return channel->width;
}

Offline

 

#2 2010-10-10 07:58:04

Crayon
Bad Mother Fucker

Re: About GRRMOD

GRRMOD is a side project and is far from being completed. You could mess around with the code but we will not give a lot of support.

To use MP3, in GRRMOD_core.c: http://code.google.com/p/grrlib/source/ … _core.c#44
Comment line 45 and uncomment 46.

The code is not complete, when the song is finished instead on restarting in will simply crash (from what I remember). Plus there is a lot of other incomplete functions. Feel free to help...

PS: I think it does not work anymore with the newest libogc version.

Offline

 

#3 2010-10-10 08:22:34

panox
Member

Re: About GRRMOD

Oh, that's it, now i understand, thanks a lot Crayon, nice work, i'll try make it play mp3 files.
The problem is only with the mp3 files, with the other files it works perfectly..
Thanks a lot smile

Offline

 

Board footer

Powered by FluxBB