SOX, LAME, and other audio functions

alt=
DannyA
@dannya
10 years ago
584 posts
Is it possible to get a breakdown of the basic functions that the audio module provides? I have my own audio module built off an early version of the audio module and it does not have all the functionality. To make it worse, i have to update every time there is a change to the audio module. It would be helpful to know what i'm missing. Can you break down what the audio module does and the flow? e.g.
1. lame- encoder converts file based on quota settings
2. Sox- ???
3. id3tagger adds tags based on metadata
4. ???
5. ???
updated by @dannya: 08/05/14 03:35:52AM
michael
@michael
10 years ago
7,718 posts
All of the code is there for you in the module, you can watch it work.

I suggest setting up xdebug and walk through the code as it runs.
alt=
DannyA
@dannya
10 years ago
584 posts
Best response yet.

I'm going to put this together with the module documentation.
https://www.jamroom.net/the-jamroom-network/documentation/modules/273/jraudio#what-does-the-audio-module-do

Thanks!
michael
@michael
10 years ago
7,718 posts
Yeah the question is a bit broad.

If your going to build documentation for others, that's awesome.

Perhaps in diagram format eg:
https://en.wikipedia.org/wiki/Jamroom#mediaviewer/File:A_diagram_of_the_routing_system_used_in_Jamroom_5.png
alt=
DannyA
@dannya
10 years ago
584 posts
Yes a diagram like that would have been perfect. I wish i had written the module so i could break it down like that. it was exactly what i was looking for. Do you know who created the diagram of the routing system?
michael
@michael
10 years ago
7,718 posts
me.

I did it by setting up xdebug and walking through the code as it runs.

--edit--
I used the free trial of https://www.lucidchart.com/

Then watched xdebug as it progressed over router.php.

Whenever there was an IF(something) I would draw a decision diagram.
updated by @michael: 07/02/14 12:17:20AM
alt=
DannyA
@dannya
10 years ago
584 posts
Michael,

Unfortunately, I'm not a developer;i was trying to understand what the module does. As much as i would like to try and figure out the code, if I thought i could do that accurately, I would not have asked the question or looked for documentation.

In other words, to paraphrase this interaction:
Me: Can you provide more detailed documentation
You: You should figure it out for yourself, and then write the documentation for us.

Not the response i was looking for.
brian
@brian
10 years ago
10,148 posts
Yeah we can't really expect to use xdebug and walk through it - that's not realistic ;)

so the audio/video module both use ffmpeg, which is provided by the core:

jrCore/tools/ffmpeg

ffmpeg is used to:

- convert audio formats from one format to another
- convert video formats from one format to another
- "grab" a video image from the middle of a video file

the audio module also includes:

jrAudio/tools/sox - it is used to "fade in" and "fade out" the audio sample (if one is created)
jrAudio/tools/id3v2 - adds ID3 tags to MP3 files

I know you have developers working for you - they can simply make system() calls to these binaries and use them for whatever means you would like.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
SteveX
SteveX
@ultrajam
10 years ago
2,584 posts
Danny, the ffmpeg and sox stuff was all working back around December, but the mp3 tagging has been added in more recently.

It looks like there are some new views in the audio module as well which deal with mass reconverting.

Your developers should have no problems copying the views and function into your custom modules, I've jsut taken a look at the jrAudio changes for 2014 and it should be perfectly straightforward if you need those new features (I can't imagine you will be changing your label's licensed files though so I doubt you will need them).


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
alt=
DannyA
@dannya
10 years ago
584 posts
That's the reason for my question.
I don't know what ELSE the audio module does; so I'm trying to understand the full scope and flow of the module. Right now i'm discovering tools after the fact. e.g. the sample file trimming is not available in my custom module; that was added later.

Also, I want to additional functionality to the process when a song is created. e.g. GRiD generation, bpm detection, key generation, additional format conversion. Having an understanding of the existing process would help me figure out the best time to do that.

Finally, I was considering separating the entire media "processing" to be handled on s separate server. i.e. having a separate server handle the heavy lifting of transcoding and processing by other tools. This would take a lot of load of the server and could be scaled separately.
SteveX
SteveX
@ultrajam
10 years ago
2,584 posts
Your GRiD number is created in the create_save function:
    // media needs a unique grid id 
	$_core['audio_grid'] = xtSong_create_media_grid($_rt['_profile_id'],$_rt['_item_id']); //userId, songId
	jrCore_db_update_item('xtSong',$aid,null,$_core);
You'd add your other custom functions into the create_save in a similar fashion.

You already have the file from this line:
$_fl = jrCore_get_uploaded_media_files('xtSong','audio_file',$_user['user_active_profile_id']);

So you'd use $_fl for any functions that require the file (bpm detection etc) and then save that to the song data in the db.

For anything like additional format conversion, you might do that in the create_save function as well, or possibly in a save_media_file listener. (look at jrVideo_save_media_file_listener for an example of that (it runs the jrCore_get_media_file_metadata function), jrAudio runs the same jrCore_get_media_file_metadata function from the create_save function.

In a nutshell, jrAudio doesn't do any of the things that you wnat it to do, so you need to write the custom functions that do those things, then run those functions in the xtSong_create_save function, have the functions return the info that you need to save to the db, and then add it to the $_rt array when the item is created, or to the $_core array if you need the item id before you run your function (like it does with the GRiD generation where the song id is needed in oreder to create the GRiD).

I don't have the first clue as to how to hand any processing off to a second server.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

updated by @ultrajam: 07/02/14 03:55:55PM
michael
@michael
10 years ago
7,718 posts
andersda:...
In other words, to paraphrase this interaction:
Me: Can you provide more detailed documentation
You: You should figure it out for yourself, and then write the documentation for us.

Not the response i was looking for.

Funny, the way I read it was:
You: I did some stuff to the jrAudio module now I need to re merge it. Would someone do all the leg work for me so I don't have to.
Me: Nope, if you want to do it you have to do it yourself just like anybody answering you would have to. If your willing to share that with everyone, great. (as we are open source now.)

Interesting how we everyone interprets things differently.
alt=
DannyA
@dannya
10 years ago
584 posts
I guess that's a start. I feel this module does allot more though. Here's the thing. I branch the audio module, or create my own, I don't know what else I might be missing that other modules depend on.

Don't other modules hook into the audio module? How do I know if a module has a dependency on the audio module. The biggest thing is the player and understanding how it interacts with the media.

I guess a flowchart would not help in this case anyway
michael
@michael
10 years ago
7,718 posts
You shouldn't need to branch/clone/copy a module. Use the events and listeners system to tap into its functionality.

"Events and Listeners"
https://www.jamroom.net/the-jamroom-network/documentation/development/1011/events-and-listeners

If your wanting to tap into a location where there is no event, ask for one to be put into that location, or ask which event to use to get xxxxxxxxxxx done. That would be an easier question to answer.

Tags