I want to try to create a program to create / edit any music. Purely for educational purposes, I want to learn how to work with music files, change them, create ...

I know that there are formats with and without track compression. For example, the same .aiff, but do not open it just like a notepad. How to create your own .aiff? How to write in it a couple of seconds of sounds and get its structure, to change, study?

There is MIDI. Everything is easier with him, but there are less opportunities. The musical range limits the possibilities, but it can be converted to MusicXML and vice versa and thus created, edited.

Why so much fuss with the same .mp3? This is a popular format, there should be a lot of information on the Internet about how to change it, but I don’t find anything other than getting track tags using ID3 (in PHP).

How to convert any format into editable code (for example .XML) and back and what can you do with a track?

I have confusion in my head about this, I hope that there is a person here who will explain how it works.

P.S. I hope to work on JS, NodeJS, PHP, if it is possible, I don’t intend to create extremely powerful editors, I want to understand how it works, create a small (even ugly) track through PHP and that's it.

  • And how do you imagine converted mp3 to MusicXML? mp3 is roughly packaged samples. And MusicXML (like midi) is just recorded notes. But in general, if you really want to work with mp3 - with ffmpeg you convert to pcm (raw format). And there it is already easy. And then after editing you pack it again. - KoVadim
  • The fact of the matter is that I don’t even imagine it for myself @KoVadim :) The point is that I basically don’t understand what it looks like .mp3, but I assume that you can create it manually. - Telion
  • one
    Yes, it can be made manually. And the easiest way is to generate a pcm file and then convert it using ffmpeg. - KoVadim
  • @KoVadim thanks, I will look for how to do it. - Telion
  • 2
    I can write an answer, but it will take a lot of space and time. Yes, it seems that AIFF is the usual pcm. How to read? any hex editor. In php open the file as binary. Just do not expect text there - there is just an array of bytes. - KoVadim

1 answer 1

It is possible, here it is written how to do this using php http://www.theblog.ca/merge-mp3s-php

<?php // This is the class to generate mp3 files based on the anti-spam words // Based on the PHP mp3 class at http://www.sourcerally.net/Scripts/20-PHP-MP3-Class // Output code based on the FPDF class at http://www.fpdf.org class mp3 { var $str; var $time; var $frames; // Create a new mp3 function mp3($path="") { if($path!="") { $this->str = file_get_contents($path); } } // Put an mp3 behind the first mp3 function mergeBehind($mp3) { $this->str .= $mp3->str; } // Calculate where's the end of the sound file function getIdvEnd() { $strlen = strlen($this->str); $str = substr($this->str,($strlen-128)); $str1 = substr($str,0,3); if(strtolower($str1) == strtolower('TAG')) { return $str; } else { return false; } } // Calculate where's the beginning of the sound file function getStart() { $strlen = strlen($this->str); for($i=0;$i<$strlen;$i++) { $v = substr($this->str,$i,1); $value = ord($v); if($value == 255) { return $i; } } } // Remove the ID3 tags function striptags() { //Remove start stuff... $newStr = ''; $s = $start = $this->getStart(); if($s===false) { return false; } else { $this->str = substr($this->str,$start); } //Remove end tag stuff $end = $this->getIdvEnd(); if($end!==false) { $this->str = substr($this->str,0,(strlen($this->str)-129)); } } // Display an error function error($msg) { //Fatal error die('<strong>audio file error: </strong>'.$msg); } // Send the new mp3 to the browser function output($path) { //Output mp3 //Send to standard output if(ob_get_contents()) $this->error('Some data has already been output, can\'t send mp3 file'); if(php_sapi_name()!='cli') { //We send to a browser header('Content-Type: audio/mpeg3'); if(headers_sent()) $this->error('Some data has already been output to browser, can\'t send mp3 file'); header('Content-Length: '.strlen($this->str)); header('Content-Disposition: attachment; filename="'.$path.'"'); } echo $this->str; return ''; } } ?> 
  • Here it is shown how to connect the tracks, or rather, the example shows how to connect them in the correct order, but the question is can the track itself be somehow changed? Open the track code and write something there, so that after editing you get a working new track. - Telion
  • Then on PCP there are no ready things that you want. I just wanted to help. - L. Vadim