Examples of using Echo with SGDK?

SGDK only sub forum

Moderator: Stef

S. P. Gardebiter
Newbie
Posts: 5
Joined: Mon Nov 18, 2013 10:42 pm
Location: Germany

Examples of using Echo with SGDK?

Post by S. P. Gardebiter » Tue Nov 19, 2013 12:50 am

Hello,
I'm trying to figure out how to make Echo work with SGDK and it's certainly not easy. Trying to include and compiling it is not easy as well, not only the missing stdint.h is causing trouble but I get weird compiler errors when I include it (for example .h files from recourses suddently do not recognise the datatype "u8"). Also all these C abstractions like void pointers sometimes give me headaches as well, in my opinion pointers are a lot easier to use in assembly because there is not so much stuff going on in the background.
I'm still relatively new to SGDK but I wanted to start with the sound/music because I tought that this field is usually causing the most trouble (and I was right). I can't use SGDKs internal drivers because they're just too slow for my needs (I need PCM for the drums because otherwise they sound horrible), I'm stuck with MIDIs here and there is only a midi2vgm converter (VGMGen) and nothing else.

If someone could link me to a tutorial, give me an example or explain this stuff to me, I would greatly appreciate it.

Also, please note that I'm not trying to programm a demo or anything, I'm trying to make a game.

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Tue Nov 19, 2013 1:12 am

These might be helpful to you, when I was working with SGDK+Echo:

viewtopic.php?p=16160

This is a post where I listed the steps involved in getting data into Echo:

viewtopic.php?p=16104#16104

S. P. Gardebiter
Newbie
Posts: 5
Joined: Mon Nov 18, 2013 10:42 pm
Location: Germany

Post by S. P. Gardebiter » Tue Nov 19, 2013 1:59 am

I already read some of your threads, when I was searching for a solution before. :)
Didn't help me though.

Code: Select all

#define uint8_t u8
#define uint16_t u16
#define uint32_t u32
#define int8_t s8
#define int16_t s16
#define int32_t s32 
To make these lines of code work I have to include genesis.h in echo.c, however if I do so, I get a ton of weird compiler errors sooner or later (like I said, .h files from recourses suddenly don't recognise data types). Don't ask me why but that has happened to me. The SGDK compiler isn't very helpful with it's error messages either.

I didn't have much trouble trying to figure out how to convert stuff (I'm not going to use any tracker anyway) but more with the usage of echo itself as a C library (hence why I asked for a fully-fledged example). Also I read something about errors that occur when your recourses are on adresses bigger than 0x8000, I wonder how things are supposed work out, when you have a lot music files. I've read your post about the instrument lists as well, that one piece of code was even more confusing. Why does everything always have to be so compliated? :S
Gives me the feeling that this would be even easier to implement in assembly because you have more control over the things you want to do and there isn't so much weird stuff going on in the background.

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Tue Nov 19, 2013 4:16 am

You can also try to get in touch with sikthehedgehog and Oerg688, see if they can help you.

Unfortunately, you won't find any tutorials. The community's pretty small so it's not as well served as, say, nesdev. Not a lot of people have been asking about or using Echo. You'll have to muddle your way through until you figure it out.

kubilus1
Very interested
Posts: 237
Joined: Thu Aug 16, 2012 2:25 am
Contact:

Post by kubilus1 » Wed Nov 20, 2013 11:28 pm

The VGM driver in SGDK can do PCM, but is limited to 8kHZ samples. The nice thing about that is you simply need to:

SND_startPlay_VGM(yoursong);

Of course, Echo is more advanced, though I don't have any experience getting this to work with SGDK.

S. P. Gardebiter
Newbie
Posts: 5
Joined: Mon Nov 18, 2013 10:42 pm
Location: Germany

Post by S. P. Gardebiter » Fri Nov 29, 2013 12:16 pm

After many hours of frustration and trying destroy my computer euqipment, I've managed to make (most stuff) work.

main.c

Code: Select all

#include "main.h"

int main(void)
{

        // Initialize Echo
        echo_init(Instruments);        // Load Instruments
        echo_set_pcm_rate(4);        // Default PCM Rate
        echo_play_bgm(testflute);    // Play your Song

        JOY_init();

        // Mainloop
        while(1)
        {
                // Wait for screen refresh
                VDP_waitVSync();
        }

        // This will never be reached :(
        return(0);
}
It's really important that you copy echo.c and echo.h, echoblob.h into the same folder as your project, otherwise you might get compiler errors. Include echo.h in your main.h. Edit echo.h and replace #include <stdint.h> with #include "echoblob.h".
Replace ther following code in echo.c:

Code: Select all

#include <stdint.h>
#include "echoblob.h"
#include "echo.h"
with:

Code: Select all

#include "main.h"
Copy the following code into main.h:

Code: Select all

#include "testflute.esf"
#include "flute.eif"

static const void* const Instruments[] =
{
            flute,
            NULL
};
Also don't forget to add test-flute.esf (rename it to testflute.esf) and flute.eif to your project.
Everything should work now.
djcouchycouch wrote:Unfortunately, you won't find any tutorials. The community's pretty small so it's not as well served as, say, nesdev.
And I can tell you that it will stay that way, aslong as nobody is going to write any tutorials or give atleast examples about the most basic things of Megadrive development. :/
kubilus1 wrote:The VGM driver in SGDK can do PCM, but is limited to 8kHZ samples. The nice thing about that is you simply need to:

SND_startPlay_VGM(yoursong)
The problem with that is, that it's not fast enough for my needs. Songs with samples are pretty slow using the VGM driver.
The driver is fine for everything not using samples though.

kubilus1
Very interested
Posts: 237
Joined: Thu Aug 16, 2012 2:25 am
Contact:

Post by kubilus1 » Fri Nov 29, 2013 5:15 pm

The problem with that is, that it's not fast enough for my needs. Songs with samples are pretty slow using the VGM driver.
The driver is fine for everything not using samples though.
Yeah, there a couple different ways that PCM samples are represented in VGM files. One way is much less efficient and tends to have the samples play way too slowly with the VGM player in SGDK.

I have been working on a program to convert the inefficient format to the more efficient format. This actually results in much smaller files as well.

It sounds like you have Echo up and going, though, so that should do well for you.

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Fri Nov 29, 2013 9:45 pm

S. P. Gardebiter wrote:
djcouchycouch wrote:Unfortunately, you won't find any tutorials. The community's pretty small so it's not as well served as, say, nesdev.
And I can tell you that it will stay that way, aslong as nobody is going to write any tutorials or give atleast examples about the most basic things of Megadrive development. :/
aouch...it's rude :( edit : difficult to hear that
did you follow the SGDK tutorial ?
and no, sorry, Echo isn't basic thing.
It took perhaps 10 years to get this driver....
Last edited by KanedaFr on Fri Nov 29, 2013 11:30 pm, edited 1 time in total.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Fri Nov 29, 2013 10:59 pm

Be careful with "rude" word in english which does not mean the same as in french (i often did the mistake myself) :p
But you're right Kaneda, he was a bit rough when he said "no basic tutorial", there are basic tutorials... but i also agree that i really have to make more and update the old ones ;)

S. P. Gardebiter
Newbie
Posts: 5
Joined: Mon Nov 18, 2013 10:42 pm
Location: Germany

Post by S. P. Gardebiter » Sat Nov 30, 2013 7:42 am

kubilus1 wrote:Yeah, there a couple different ways that PCM samples are represented in VGM files. One way is much less efficient and tends to have the samples play way too slowly with the VGM player in SGDK.
Good to know. But what I mean is, for example, that is one of the pieces of information that is really hard to find. :?
KanedaFr wrote:aouch...it's rude :(
I'm sorry, this wasn't directed at Stef or anyone helping him. I think you did a great job and gave the community a lot but the community has to give something back and help with the project, in my opinion. :P
I'm not going to grumble about something and then do nothing anyway, in fact I already offered Stef my help and I hope that that Stef has no problem with me being a bit too straightforward sometimes (you don't want to see me when I'm programming and things don't work, I'm like a freaking vulcano sometimes).
KanedaFr wrote:difficult to hear that
did you follow the SGDK tutorial ?
A lot of it, yeah. Problem is that it mostly cover graphics stuff only. I had a lot problems getting stuff to work and got weird errors and that is because I didn't knew that you have to put sources, headers and resources into specific directories to make it work.
There were other subtle things as well, that made me kinda frustrated.
It's all good though, I know about this stuff now and here I am to deliever it to posterity. :P
KanedaFr wrote:and no, sorry, Echo isn't basic thing.
It took perhaps 10 years to get this driver....
Ah, I think you got me wrong there. I wasn't refering to Echo but to music playback with PCMs and other stuff, that isn't there in the basic tutorial. With the VGM driver you can't also play SFX at the same time, as far as I know (if that's outdated information, then sorry), wouldn't you call this basic functionality?

kubilus1
Very interested
Posts: 237
Joined: Thu Aug 16, 2012 2:25 am
Contact:

Post by kubilus1 » Sun Dec 01, 2013 4:21 am

If you think that what is needed is tutorials, then write some tutorials. That's kind of how this whole open source community project stuff works. You have an itch so you scratch it.

When you say that the community needs to give back, I'm just very confused by that statement. *This* is the community, or at least a decent part of the Genesis development community. You have a lot of people on here that spend their time to learn and development for a discontinued platform. We give back when we answer questions to people on the forums, or when KanedaFr spends resources to keep this site going, or Stef works on SGDK, or TmEE works on awesome sound stuff, and many other people show the projects they are working on or share the code snippets they are struggling with.

I joined this community about a year ago. I wanted to be able to develop on Linux so I took a lot of the awesome work by Chilly Willy and packaged it up to make the build environment setup a bit easier. I then put that code out into the wild for others to use, and give feedback on. I wanted a way to play tunes created in Deflemask without using up the main CPU so I wrote the Z80 VGM driver (based off some code by Sigflup). Stef then incorporated that into SGDK.

I want to add sound FX support to the driver as well at some point, but I'm also working on quite a number of other projects. Some related to making it simpler to program with the SGDK kit, and some others completely unrelated to anything I would post on here. Plus, real life and work.

My point is, I had a particular itch, so I scratched it. I didn't expect some else to do so for me, and I learned quite a bit in the process.

MrTamk1s
Very interested
Posts: 75
Joined: Sun Jan 04, 2015 10:27 pm
Location: Pennsylvania
Contact:

Some errors

Post by MrTamk1s » Thu Jan 15, 2015 4:01 am

S. P. Gardebiter wrote:After many hours of frustration and trying destroy my computer euqipment, I've managed to make (most stuff) work.

SNIP

Copy the following code into main.h:

Code: Select all

#include "testflute.esf"
#include "flute.eif"

static const void* const Instruments[] =
{
            flute,
            NULL
};
Also don't forget to add test-flute.esf (rename it to testflute.esf) and flute.eif to your project.
Everything should work now.
Read this thread in order to port my Echo engine from a cancelled BEX project to SGDK, but had some problems.

Not to necrobump, but the #include'ing of the .esf and .eif files technically should not work under C. When I tried that in Code::Blocks, I kept getting compiler errors of "stray ‘\[insert octal code of ASCII character]’ in program. This is because the #include command parses the file in question as a C file in order to find more source code. Since .eif and .esf are binary data files, the compiler tries to parse non-sense and unprintable ASCII characters as C code :roll:. Just to point that out to somebody else who finds this thread useful and is confused why that part of the guide is not working...

Instead, I used the latest version of SGDK's ResComp to compile those .esf/.eif/.ewf echo files and to create a .s and a .h file. Create a .res file, with for each echo file "BIN", "[Pointer variable Name to file]", and "[relative echo file path]"; i.e,:

Code: Select all

File: mus.res

BIN sfx_01 "music/s_01.esf"
BIN PCM_01 "pcm/s_HiLite.ewf"
BIN FM_1_01 "fm/1_01.eif"
[ETC]
Then run ResComp on the resource file, which will create .s and .h files. Finally, copy this code into into main.h:

Code: Select all

#include "echo.h"
#include "[compiled resource file.h]"

static const nullptr const Instruments[] =
{
    [Insert array list of file pointer names for instruments in order; ex: sfx_01
};
SGDK homebrew dev and Unity3D Indie dev.
Sega does what Nintendont!

Mills
Interested
Posts: 34
Joined: Fri Apr 11, 2014 11:09 pm

Post by Mills » Tue Jul 14, 2015 11:55 am

I'd love to use this for my jukebox program.

But i just didn't understand what i need to play echo music using GBDK.

Can anybody post a very simple source playing a echo song using GBDK?

Thanks a lot!

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Tue Jul 14, 2015 1:02 pm

What are you looking for ?

Play a song ?
https://bitbucket.org/SpritesMind/genre ... o.c?at=dev

Play a sfx ?
https://bitbucket.org/SpritesMind/genre ... c.c?at=dev

I'm using this driver
https://bitbucket.org/SpritesMind/genre ... ls/?at=dev
with this binary
https://bitbucket.org/SpritesMind/genre ... bin?at=dev
also available at Sik's page
https://github.com/sikthehedgehog/Echo/ ... ster/built



To play a Echo song or sfx isn't that difficult...
To CREATE a Echo song or sfx is another story....

Mills
Interested
Posts: 34
Joined: Fri Apr 11, 2014 11:09 pm

Post by Mills » Tue Jul 14, 2015 1:15 pm

KanedaFr wrote:What are you looking for ?

Play a song ?
https://bitbucket.org/SpritesMind/genre ... o.c?at=dev

Play a sfx ?
https://bitbucket.org/SpritesMind/genre ... c.c?at=dev

I'm using this driver
https://bitbucket.org/SpritesMind/genre ... ls/?at=dev
with this binary
https://bitbucket.org/SpritesMind/genre ... bin?at=dev
also available at Sik's page
https://github.com/sikthehedgehog/Echo/ ... ster/built


To play a Echo song or sfx isn't that difficult...
To CREATE a Echo song or sfx is another story....
Thanks i think I got it.

I have to use rescomp to include all song sequences and instruments, then I declare them as in the code of the first link, and that's it.

I'll try to create echo songs from XM files, maybe the music part it easier for me. :?

Post Reply