[Tool]Pokitto Music Tracker

Any news on this?

I have been busy putting up the store. Will get back to this soon.

Edit: I will release (unfinished) code this weekend so you can get to play with it.

Only saving to disk is not functional at the moment

2 Likes

@jonne at last commit on mbed, in HWSound.cpp and in pokSoundIRQ() function definition of “uint8_t output” variable removed. But variable used in function. I think you accidentally deleted variable definition. Please take a look

2 Likes

Thanks I will

EDIT

@NullMember its fixed now. Thanks for the heads up.

Remember to right click -> update library in your existing projects

2 Likes

Whoa. You’re really fast. Thanks :slight_smile:

1 Like

I could help getting this thingy ready. But I have to finish implementing Bytebeat background music to my Mars Attack game first.
Seems that Github has not been updated for a while.

Is the SD card handling the biggest problem currently?

2 Likes

Yep. We need to be able to include SDFileSystem and petitfatfs at the same time. Problem comes from the fact that since both are derived from elmChans fatfs, the variables and functions have identical names.

Ok. Why is that? I thought they were alternative solutions.

Do the functions with the same names behave differently?

If not then we could modify them to use the exact same functions under the hood.
If they are different, we could stuff them into separate namespaces.

That’s exactly what is needed or then isolate them within ifdef…endif blocks.

The problem is that both mbed online and Platformio try to compile all .cpp files. So even if similar name function is not used, it will interfere.

#ifdef/#endif won’t save you but I’m reasonably sure that if they’re in different namespaces then the name mangling process should stop them conflicting, even at the object code level.

1 Like

I am now going to start work on this. First try to get SDFileSystem to work.

1 Like

I have made some tweaks (not yet made a PR) and now writing and reading from SD works with SDFileSystem in EmBitz. I have not excluded any files from the test project so hopefully it works in MBed too. This is the test app. It creates a directory on SD and writes a file to it.Then it reads the same file. PetitFS test tries only to read from that file.

#pragma GCC diagnostic ignored "-Wwrite-strings"

#include "Pokitto.h"
#include "SDFileSystem.h"

Pokitto::Core mygame;

FILE *fp = NULL;

int main () {

    mygame.begin();
    mygame.display.persistence = true;

#ifdef NOPETITFATFS

    // *** Test SDFileSystem

    SDFileSystem sd(/*MOSI*/P0_9, /*MISO*/P0_8, /*SCK*/P0_6, /*CS*/P0_7, /*Mountpoint*/"sd");

    // Write to a directory in SD.
    mkdir("/sd/mydir", 0777);

    fp = fopen("/sd/mydir/sdtest.txt", "w");
    if(fp == NULL) {
        mygame.display.println("Could not open file for write");
    }
    fprintf(fp, "Hello SD Card!");
    fclose(fp);

    mygame.display.println("Wrote to SD!");

    // Read from SD
    fp = NULL;
    char* filePathAndName = "/sd/mydir/sdtest.txt";
    fp = fopen(filePathAndName, "r");
     if(fp == NULL) {
        mygame.display.println("Could not open file for read");
    }
    mygame.display.println("Read from SD:");
    while(true) {
      char c = fgetc(fp);
      if( feof(fp) ) break;
      mygame.display.print(c);
   }
   fclose(fp);

#else

    // *** Test PetitFatFS

    pokInitSD();
    char* filePathAndName = "mydir/sdtest.txt";
    (void)fileOpen(filePathAndName, FILE_MODE_READONLY);
    mygame.display.println("Read from SD:");
    while(true) {
      char c = 0;
      uint16_t len = fileReadBytes((uint8_t*)&c, 1);
      if( len == 0 ) break;
      mygame.display.print(c);
    }
    fileClose(); // close any open files

#endif

    while (mygame.isRunning()) {
        if (mygame.update()) {
         }
    }
}

Edit: So I suppose the SD is ready for PokiTracker. Are the sources somewhere available?

Edit2: Some parts of the sound implementation in PokittoLib are dependent on PetitFatFS, and they must be changed if PokiTracker uses them, or PetitFatFS and SDFileSystem must co-exist. Whichever is easier to do.

4 Likes

I began to think that having both file systems at the same time could be the best solution. Then we could remove all NOPETITFATFS define handling. I made a separate namespaces for each ChaNs FS classes implementation to keep them separate as @Pharap suggested.

Now both systems work without NOPETITFATFS. Thought I am not sure if it can cause trouble if we are alternating the commands of different file systems… But my initial test looks to work anyway :slight_smile:

I will try some of the old test programs first and then make a PR.

2 Likes

Excellent, I had a feeling it would work.

Good point.

There are some other PRs outstanding.
Hopefully they won’t conflict.

Ah? OK. Will check them in.

1 Like

Yes, it is much easier to use a namespace than renaming each function, typedef, etc. :slight_smile:

About the two parallel filesystems: Ideally, we could manage with one “official” FS. I remember @jonne mentioned about PetitFatFS being more performant. Either that or significant ROM savings would be good enought reason to keep two parallel FSes.

I just wonder if I need to make some rudimentary cross-FS checks to prevent the nasty bugs to surface because of using both FS sessions at the same time. Apart from the obvious case of writing to the same file that is being reading from (e.g. in the sound interrupt handling function), is there other, low-level, hazards in this scenario? How the SPI/SD interface tolerate having two different FS sessions at the same time? I mean the case when totally different files are being accessed via each FS?

1 Like

Super cool project! I can’t really do anything music-related but I’m super excited by the prospect of a tracker running on the Pokitto :smile:

1 Like

@jonne Is there the latest version in the examples/Tracker project, so I can make improvements over that?

yes it is the latest version

1 Like