Need help to see if this works

Hey guys, I’m just about finished with my 2nd pokitto game, but I’m having issues getting the music to play on the real hardware.

After about 2 hours of changing code and the way it’s done, I’m still nowhere done.

What I’ve done now is to make a simple project below:

import upygame as upg
import umachine
import pics

upg.display.init()
screen_sf = upg.display.set_mode() # full screen

g_sound = upg.mixer.Sound()

# Set palette
upg.display.set_palette_16bit([0,4124,1984,65535]);

menuSong = ""

gpioPin = umachine.Pin ( umachine.Pin.EXT2, umachine.Pin.ANALOG_IN )
gpioPinValue = gpioPin.value()
if(gpioPinValue == 0):
    isThisRealHardware = False
else:
    isThisRealHardware = True
    menuSong = "pokaquar/menuSong.wav"

class Music:
    def __init__(self, isThisRealHardware, menuSong):
        self.isThisRealHardware = isThisRealHardware
        self.menuSong = menuSong
        print ("moo: " + self.menuSong)
        
    def stopMusic(self):
        if (self.isThisRealHardware):
            g_sound.play_from_sd("dummy.raw")   # This file does not exist
        
    def playMenuMusic(self):
        if (self.isThisRealHardware):
            g_sound.play_from_sd(self.menuSong)
        

music = Music(isThisRealHardware, menuSong)
music.playMenuMusic()

while True:

    umachine.draw_text(10, 10, "hello world", 4)

    upg.display.flip()

For some reason, in the emulator, the programs run fine, but obviously the music won’t work on there.
However, on the real hardware, I get a blank screen and nothing else.

Can any of you check out the above code’s bin file to see if you hear any music and see the hello world text on your pokittos?

If yours works, then mine has died.
On the other hand, if it doesn’t work for you either, could you let me know what I’ve done wrong in that code above to freeze the system?

It goes without saying that I have that folder and file on my SD card…

Hello MicroPython Test.bin (169.5 KB)

Here’s the zip file with the audio file in:
pokaquar.zip (1.6 MB)

EDIT: To clarify:

  1. The raw audio file used is one from PokittoBloids, so there’s no issue there.
  2. I’ve now removed the class code and did a direct call before the while loop:
...
if (isThisRealHardware):
    g_sound.play_from_sd(menuSong)
    print ("moo: " + menuSong)

while True:
...

Still hangs my pokitto as before.

The code looks ok to me. Have you tried another SD card?

Looks to me after much more testing and changing, it might be a filename length issue.
I had

pokaquar/menuSong.wav

And it hangs. I then changed it to:

pokaquar/test.wav

and it works.

What is the total length or folders and filenames? I thought each could be 8 letters long…

1 Like