Code Monkey home page Code Monkey logo

midi2mp3-api's Introduction

midi2mp3-api

REST API (Docker, PHP, Slim, FluidSynth, Lame) for MIDI to MP3 convertion.

Prerequisite

Start

Installation

composer install

Build

docker image build -t midi2mp3-api .

Run

docker run -p 80:80 midi2mp3-api

API Usage

Endpoint http://[docker-machine]/info

Request

  • Verb : GET
  • No parameter

Response

  • Content-Type : Application/json
{
  "apiName": "midi2mp3",
  "version": "1",
  "description": "Midi to MP3 Convertion"
}

Endpoint http://[docker-machine]/convert

Request

  • Verb : POST
  • Content-Type : Application/json
  • Parameters : -- midiData : Base64 encoded Midi file
{
  "midiData": "TVRoZAAAAAYAAQACAYBNVHJrAAAAUwD/Aw1jb250cm.....AP8BC"
}

Response

  • Content-Type : Application/json
{
  "statusCode": "OK|ERROR",
  "message": "Information complement on error",
  "base64Mp3Data": "oAsAdkAJA8WoMAkDwAAJA+WoMAkD4AAJBAWoMAkEAAAJB....vAA==",
  "logs": [
    {
      "title": "FluidSynth : midi -> wav convertion",
      "content": "FluidSynth log details"
    },
    {
      "title": "Lame : wav -> mp3 convertion",
      "content": "Lame log details"
    }
  ]
}

Also read

midi2mp3-api's People

Contributors

ggracieux avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

edwala

midi2mp3-api's Issues

Switch all API output to english

Expected behavior

ALL API output should be in english

Actual behavior

all fields are in english except 'message' and log.title

{
  "statusCode": "ENGLISH",
  "message": "FRENCH STUFF",
  "base64Mp3Data": "RAW DATA",
  "logs": [
    {
      "title": "FRENCH STUFF",
      "content": "ENGLISH"
    },
    {
      "title": "FRENCH STUFF",
      "content": "ENGLISH"
    }
  ]
}

Steps to reproduce the problem

  1. Run midi2mp3-api docker image
  2. POST the following JSON to http://[docker-machine]/convert
{
  "midiData": "TVRoZAAAAAYAAQACAYBNVHJrAAAAUwD/Aw1jb250cmAP8BC",
  "soundfont": "bagpipes"
}

Same problem with the /info endpoint

{
   "apiName":"midi2mp3",
   "version":"1",
   "description":"FRENCH STUFF"
}

Generated MP3 file has no sound

Expected behavior

Generated MP3 shoud sound like the midi file ....

Actual behavior

The WAV file is produced, duration seems good but it has no sound at all.
MP3 file is produced from WAV, it does not have any chance to produce any sound.

Steps to reproduce the problem

  1. Run midi2mp3
  2. POST the following json to the /convert endpoint
{
  "midiData": "TVRoZAAAAAYAAQACAYBNVHJrAAAAUwD/Aw1jb250cm9sIHRyYWNrAP8BCWNyZWF0b3I6IAD/AR5HTlUgTGlseVBvbmQgMi4xOC4yICAgICAgICAgICAA/1gEBAISCAD/UQMKLCoA/y8ATVRyawAABg8AsAdkAP8DBVxuZXc6AP9ZAv0AAJA4WgqQOAABkDhaCpA4AAGQP1oKkD8AAZA+WgqQPgAAkD9ahECQPwAAkEFaYJBBAACQQ1o0kEMAAJBEWgqQRAABkERaCpBEAAGQQVoKkEEAAZBDWgqQQwABkEFagUCQQQAAkD9agTWQPwAAkERaCpBEAAGQOlqBQJA6AACQP1qBFJA/AACQRFoKkEQAAZBEWgqQRAABkEFaCpBBAAGQQ1oKkEMAAZBBWoRAkEEAAJBDWoE1kEMAAJBBWgqQQQABkENahXWQQwAAkERaCpBEAAGQQ1qEQJBDAACQRFpgkEQAAJBGWlWQRgAAkENaCpBDAAGQRFqBQJBEAACQQ1qBNZBDAACQRFoKkEQAAZBBWoFAkEEAAJA/WoEUkD8AAJBEWgqQRAABkERaCpBEAAGQQVoKkEEAAZBDWgqQQwABkEFahECQQQAAkENagQqQQwAAkDpaCpA6AACQOloKkDoAAZA4WgqQOAABkDpaCpA6AAGQOFoKkDgAAZA6WoVUkDoAAJA4WgqQOAABkDhaCpA4AAGQP1oKkD8AAZA4WgqQOAABkDxahECQPAAAkD5aYJA+AACQP1pVkD8AAJA+WgqQPgABkD9agUCQPwAAkDpagTWQOgAAkD9aCpA/AAGQPlqBQJA+AACQP1qBH5A/AACQRloKkEYAAZBGWgqQRgABkERaCpBEAAGQRlqEQJBGAACQRFqBNZBEAACQRloKkEYAAZBDWoVUkEMAAJBE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FqBNZA8AACQOFoKkDgAAZA6WoJ1kDoAAJBEWgqQRAABkDpaYJA6AACQPFpgkDwAAJA+WoEUkD4AAJBEWgqQRAABkERaCpBEAAGQPFoKkDwAAZA/WgqQPwABkDxahECQPAAAkDpaf5A6AACQRFoKkEQAAZBEWgqQRAAAkDpaCpA6AAGQOFoKkDgAAZA6WgqQOgABkDhaCpA4AAGQOlqMAJA6AAD/LwA=",
  "soundfont": "bagpipes"
}
  1. Enter runing container and get sessionId path for this convertion
docker ps
docker exec -it [containerID] bash
ls /tmp/midi2mp3
exit
  1. Extract audio file to host
docker cp [containerID]:/tmp/midi2mp3/[sessionId]/[sessionId].midi test.midi
docker cp [containerID]:/tmp/midi2mp3/[sessionId]/[sessionId].wav test.wav
docker cp [containerID]:/tmp/midi2mp3/[sessionId]/[sessionId].mp3 test.mp3

Possible solution

FluidSynth log file can be found in the same tmp directory as the audio files.
It may have something to do with the soundfont.

fluidsynth: warning: Failed to pin the sample data to RAM; swapping is possible.
fluidsynth: warning: No preset found on channel 0 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 1 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 2 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 3 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 4 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 5 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 6 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 7 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 8 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 9 [bank=128 prog=0]
fluidsynth: warning: No preset found on channel 10 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 11 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 12 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 13 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 14 [bank=0 prog=0]
fluidsynth: warning: No preset found on channel 15 [bank=0 prog=0]
FluidSynth version 1.1.6
Copyright (C) 2000-2012 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of E-mu Systems, Inc.

Rendering audio to file '/tmp/midi2mp3/5a9e1ba723ab9/5a9e1ba723ab9.wav'..

Info endpoint should return fluidsynth and lame version

Expected behavior

{
  "apiName": "midi2mp3",
  "description": "Midi to MP3 Convertion",
  "version": {
    "api": "1.1",
    "fluildsynth": "1.18",
    "lame": "2.3"
  }
}

Actual behavior

{
  "apiName": "midi2mp3",
  "version": "1",
  "description": "Midi to MP3 Convertion"
}

Steps to reproduce the problem

  1. Run midi2mp3-api
  2. go to info endpoint : http://[docker-machine]/info

Temporary data is not deleted

Expected behavior

Temporary data should be deleted after it has been send to client.

Actual behavior

Temporary data is never removed.

Steps to reproduce the problem

  1. Send a valid request to the convert EndPoint
    2.Enter container running midi2mp3-api
    3.Look in /tmp/midi2mp3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.