Initial commit.

This commit is contained in:
iAmInAction 2022-07-02 19:23:56 +02:00 committed by GitHub
commit 038e377fb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 328 additions and 0 deletions

13
LICENSE Normal file
View File

@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

29
README.md Normal file
View File

@ -0,0 +1,29 @@
# MIDIfy
Spotify but for MIDIs
___
## Goals
This program aims to provide a usable listening experience on extremely low bandwidth and on heavly outdated hardware. Its also supposed to use as little external tools as possible for the task and to be as platform compatible as possible (except for Windows ;-b).
___
## Dependencies
This program only has three essential dependencies:
A somewhat recent version of bash, a native MIDI file player and CURL.
___
## Installation
To use this program, you need to install the `curl` package according to your OSes package managers instrucions. Under for example Debian that would be `sudo apt install curl`.
You will also need a MIDI file player. On default it tries to use `timidity` but you can change that in the configuration. Another good choice is (my own OPL3 emulator midi player)[https://github.com/iAmInActions/pioplemidi-cli] but any player should do the job.
If you have git installed, clone the program with the following command:
```
git clone http://github.com/iAmInActions/MIDIfy
```
In case your device does not support git or you simply want to not install git, download the repository as a zip file and extract it.
___
## Usage
To start the program, enter the directory and run `./midify.sh`
You can probably start using the program as is if you installed the dependencies and dont care about chaning anything. In case something isn't quite to your liking, simply edit the configuration part of `midify.sh` with an UTF-8 compliant text editor like vim or nano.
The controls are simple. A single `CTRL + C` skips a song, pressing it twice quits the program.

View File

@ -0,0 +1,2 @@
Sweden.mid
BackInBlack.mid

Binary file not shown.

BIN
library/midi/Sweden.mid Normal file

Binary file not shown.

23
library/playlists.txt Normal file
View File

@ -0,0 +1,23 @@
█▓▒░░MIDIfy░-░LOCAL░PLAYLISTS:░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓█
|----------------|------------------------------------------------------------|
| List name | Description |
|----------------|------------------------------------------------------------|
| example | An example of how to make your own playlist |
|----------------|------------------------------------------------------------|
| | |
|----------------|------------------------------------------------------------|
| | |
|----------------|------------------------------------------------------------|
| | |
|----------------|------------------------------------------------------------|
| | |
|----------------|------------------------------------------------------------|
| | |
|----------------|------------------------------------------------------------|
| | |
|----------------|------------------------------------------------------------|
| | |
|----------------|------------------------------------------------------------|
| | |
|----------------|------------------------------------------------------------|
█▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓█

161
midify.sh Normal file
View File

@ -0,0 +1,161 @@
#!/bin/bash
# MIDIfy, a FOSS Spotify-inspired MIDI-based Music Playlist streaming service.
# made by mueller_minki in 2022
# Licensed under the DO WHAT THE FUCK YOU WANT TO Public License.
# All default midi sources are credited at http://muellers-software.org/midify/sources.txt
# ---- CONFIGURATION ----
# Change the default midi player.
# 1 = timidity
# 2 = pioplemidi-cli
# 3 = custom command
MIDIPLAYER=1
# Custom MIDI player command (in case 3 is selected):
# File URL is passed as an argument behind the command.
MIDIPROG="someprogramname -argument1 --argument 2 -h -xyz"
# Change this if you want to use a 3rd party MIDIfy server.
# If this variable gets changed I am not responsible for any errors, faults, security issues or lack of source declaration. You will be entirely on your own.
MIDIFYSERVER="http://muellers-software.org/midify"
# Change this to specify a different path to your local library.
MIDIFYLOCAL="$(pwd)/library"
# Change default folder for extra files:
STUFF="$(pwd)/stuff"
# Change default folder for temporary files:
TEMP="$(pwd)/tmp"
# ---- CONFIGURATION END ----
# Cleaning up before doing anything else:
rm -r $TEMP
mkdir $TEMP
# Define Functions:
# Get a random line of a file
# Usage: $(getlineoffile <file>)
getlineoffile () {
MAXLINE=$(sed -n '$=' "$1")
LINE=$(shuf -i 1-$MAXLINE -n 1)
echo $(sed "${LINE}q;d" "$1")
}
# Run in offline mode
run_offline () {
clear && cat $MIDIFYLOCAL/playlists.txt | more
read -p "Enter a playlist name: " PLIST
if test -f "$MIDIFYLOCAL/lists/$PLIST.mm3u"
then
echo "Found the playlist."
echo "Starting playback..."
play_playlist
else
echo "Invalid playlist. Try again."
sleep 2
run_offline
fi
}
# Run in online mode
run_online () {
clear && curl -q "$MIDIFYSERVER/playlists.txt" | more
read -p "Enter a playlist name: " PLIST
status=$(curl --head --silent "$MIDIFYSERVER/lists/$PLIST.mm3u" | head -n 1)
if echo "$status" | grep -q 404
then
echo "Invalid playlist. Try again."
sleep 2
run_online
else
echo "Found the playlist. Caching to disk..."
curl -q "$MIDIFYSERVER/lists/$PLIST.mm3u" > $TEMP/playlist.mm3u
echo "Starting playback..."
play_playlist
fi
}
# Play the playlist
play_playlist () {
if [ "$mode" = "l" ]
then
# Local mode
while true
do
PLFILE="$MIDIFYLOCAL/lists/$PLIST.mm3u"
MAXLINE=$(sed -n '$=' "$PLFILE")
LINE=$(shuf -i 1-$MAXLINE -n 1)
MFILE=$(sed "${LINE}q;d" "$PLFILE")
play_song $MIDIFYLOCAL/midi/$MFILE
sleep 1
done
elif [ "$mode" = "o" ]
then
# Online mode
while true
do
PLFILE=$TEMP/playlist.mm3u
MAXLINE=$(sed -n '$=' "$PLFILE")
LINE=$(shuf -i 1-$MAXLINE -n 1)
MFILE=$(sed "${LINE}q;d" "$PLFILE")
curl -q $MIDIFYSERVER/midi/$MFILE > $TEMP/$MFILE
play_song $TEMP/$MFILE
rm $TEMP/$MFILE
sleep 1
done
fi
}
play_song () {
echo "Now Playing: $MFILE"
if [ "$MIDIPLAYER" = "1" ]
then
timidity -A 50 "$1" >/dev/null
elif [ "$MIDIPLAYER" = "2" ]
then
pioplemidi-cli "$1" -nl -fp -frb -s
elif [ "$MIDIPLAYER" = "3" ]
then
$MIDIPROG "$1"
else
echo "Internal misconfiguration. Exiting."
exit 2
fi
}
# Main process:
# Splash screen:
clear
echo ' __ __ _____ _____ _____ __
| \/ |_ _| __ \_ _|/ _|
| \ / | | | | | | || | | |_ _ _
| |\/| | | | | | | || | | _| | | |
| | | |_| |_| |__| || |_| | | |_| |
|_| |_|_____|_____/_____|_| \__, |
__/ |
v1.0, created by mueller_minki in 2022. |___/ '
echo $(getlineoffile "$STUFF/splash.txt")
# Initial selection:
read -n 1 -p "Do you want to use (l)ocal or (o)nline mode?" mode
if [ "$mode" = "l" ]
then
run_offline
elif [ "$mode" = "o" ]
then
run_online
else
echo "Not a valid mode. Exiting."
exit 1
fi
exit 0

100
stuff/splash.txt Normal file
View File

@ -0,0 +1,100 @@
Not Microsoft Edition
Has anyone seen my remote?
No one ever listens...
,pu uoy evig annog reveN
Good old simple times
Who needs X11 anyways?
TERMINALTOR
You wake up in a dark room.
Who let the dogs out?!?
Did you know that !true = false?
Kills 99.9% of bloat
DIALUP COMPATIBLE :-b
As seen in your dreams.
There are 3 Windows haters in your local area.
Ride the walrus!
All time travel to the year 2020 is prohibited.
WAYLAND has encountered an issue.
Why is it so hard to come up with splash texts?
Life hard.
Dancing queen!
dd if=/dev/random of=/dev/mybrainduringexams
rm -rf /
Did you say pineapple?
deltree %WINDIR%\system32
Located the exit. Proceed quickly.
Honey where's my supersuit?
Squirrel! Squirrel!
Anyone has a samsung?
Got any games on your phone?
Best experienced with Microsoft Internet Explorer.
Honey, I shrunk the kernel!
There are 3 hot laptops in your local area.
Are penguins to polarbears like creepers to pigs?
Dr. Freeman doesn't need to hear all this.
You are not allowed to build above the process limit.
Want you gone
The cake is a lie!
Han shot first.
Designed for GNU/Linux
Have you ever wondered why? You aren't the first one.
mlem
Gib pets
Did you know, Windows bad!
Also try Darwin!
Also try BSD!
418 I'm a teapot.
Batteries not included.
May contain traces of sh.
Baked with love.
You lost me on this one.
What is this? A motd?
Is it a bird? Is it a plane?
Every 11 minutes a Windows user rage quits.
Looking for NTLDR? Wrong place kid!
Did someone say old? This 486 is still usable!
I ACCIDENTALLY Debian a Power Macintosh G5.
Am I a bread to you?
Now with 10% less Windows support.
Still better than node.js!
Searching... Target lost. HEY! PUT ME DOWN! AAAH!
Is this just fantasy?
WE WILL ROCK YOU!
Back to Black
Name one band thats related to full bridge rectifiers.
Seriously? What did you expect?
May contain traces of else if.
May 4, be with you.
Made of 40% Iron.
WHAT? *flips tape* WHAT?
Is it because of the eye?
Good old days of 200 mb hamster wheel drives.
JUST BURN THE DARN RING ALREADY!
Overclock it!
Why compile? Why not?
I made way too many splash texts.
MuelCities: Your place on the INTERNET!
You are stuck at level 100.
*flies over and hugs you*
MissingNo.
Funny but replace N with R
Just 20 more to go.
Also try Elden Ring!
Not Grian proof.
May contain traces of salt.
Not Mac formatted.
Keyboard not found. Press F1 to continue.
if !*nix format c:
KARLSON VIBE!!!
Do not the cat
Can you unplug my WiFi?
Made of 40% Titanium!
Linux > Windows
printchar(BEL)
Now with ANSI support!
Can't run dialog. Are you using a typewriter again?
This program does not use cookies. [OK] [Fu** U]
Fits on a floppy!
Use at your own risk.
Now with brainwashing.
YAY! YOU MADE IT TO SPLASH 100!