Built In Music Player

Question:
So I am trying to make a PyPI package to add an easy way to make and play your own music. I’ve been looking over the internet to find a way to do this with Frequencies and Length Of Beat, but I can’t find anything that will work not os or Linux stuff and MacOS doesn’t have Frequencies. Preferably not a module would be best for the help.
Repl link:

https://replit.com/@SalladShooter/PunyDraftyFilesize#main.py

import music

def playSound(song, length):
    for index in range (len(song)):
        music.play(
            music.tone_playable(
                SONG[song[index]],
                music.beat(
                    LENGTH(
                        length[index]
                    )
                )
            ),
            music.PlaybackMode.UNTIL_DONE
        )
LENGTH = [1]
SONG = ["Low C"]
playSound(SONG, LENGTH)

While I’m not sure how to solve your problem, please break long lines apart for readability:

        music.play(
            music.tone_playable(
                SONG[song[index]],
                music.beat(
                    LENGTH(
                        length[index]
                    )
                )
            ),
            music.PlaybackMode.UNTIL_DONE
        )
1 Like

For real I am confused by the for loop and lists in the code.

If you are trying to make a music player why not use pygame, it is available in replit template and it can play music easily

to be honest, music in replit is really buggy (only works in edit view), and I dont think that any (or 99.99% of the) python IDEs support music, which also applies to bash and the terminal.

2 Likes

Try JupyterLab as IDE for developing audio.

I’d recommend you see librosa library too.

@TaokyleYT I don’t want to do it in Pygame, since the way I want the package to be used is in normal python projects as background music, or just to compose music.

this is technically solved but I’ll give another addition:
online ide’s (text) do this thing where they have a server specifically for being fed code and then returning text output, thus this very specific ecosystem would need major reworks to also return audio. They would need to have a dedicated package that somehow is signalling either through a separate websocket or somehow connecting to the same websocket, and it’s just a mess honestly – separate websockets are the most messy since it’s gonna have so many latency issues. Finally, even though replit has actually attempted this, it never … works because of how laggy replit is, if you thought it was laggy on returning you a few words, then it’s even more laggy trying to return entire chunks of encoded music notes, thus it almost always ends up being too slow and never actually playing

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.