The start of allowing other modules to write tags to other codecs (vorbis, flac, real, etc.), and listing them on the node.

I pulled the download link out of audio_link, because when you start adding other codecs, it gets ugly (and long)...

drewish, is there a way to hook into theme_audio_display to add more links?

Comments

drewish’s picture

i don't understand what the problem with the download link would be when you have multiple formats...

drewish’s picture

oh, also, submit typo fixes as a separate patch. those'll get committed very quickly.

q0rban’s picture

Yeah, sorry about that (typo).. It's just so small to have its own issue..

Anyways, the problem is as follows.. audio module sets its link as <a>download audio file</a>. To change this to work with multiple codecs it could insert the link as download: <a>MP3</a>, and then another module could add links after it so that it would look like this download: <a>mp3</a> | <a>vorbis</a> | <a>flac</a> | <a>real</a>..

The problem I see with that is this: audio.module is creating the initial link, but it is also creating the play count link after it. The comment module, as well as other modules, adds their links... so the final product could end up looking like this:

download: <a>mp3</a> | 3 downloads | 4 plays | <a>add new comment</a> | 5 reads | <a>vorbis</a> | <a>flac</a> | <a>real</a>

download: mp3 | 3 downloads | 4 plays | add new comment | 5 reads | vorbis | flac | real

There are also multiple multiple codecs that getID3 supports, so the list of codecs could potentially be very long...

Additional codecs also render the filelength and fileformat info inaccurate.. So the way I put it associates the fileformat as the title of the link... much cleaner IMO...

Maybe we could add a hook for the audio-info so that other modules could display list items inside it? That seems like a waste of resources for what it would do, though.. Right now I'm just overriding theme_audio_display by reloading $node->body.

I wish preview worked, because I have no idea if the above is going to display properly...

drewish’s picture

so you want to add multiple file formats on a single node? like a mp3 or wma of the same song? that's the only reason i can think you'd need multiple links...

leoburd’s picture

Hello there,

Being able to have the same audio file in multiple formats is interesting to me. I'm implementing a series of telephone-oriented modules and it would be great if I could easily store my files in both high-quality (for the web) and low-quality (for the telephone) formats.

BTW, has anyone thought about integrating automatic audio conversions (with LAME) into audio module?

Best,

Leo

q0rban’s picture

so you want to add multiple file formats on a single node?

Yes, that is exactly what I'm referring to, sorry I wasn't more specific earlier. The flash player (AFAIK) will only play mp3's, so the other codecs would only be there for downloading...

drewish’s picture

Status: Needs review » Needs work

well, i'm not opposed to the idea but i'd like to if that's the case then this patch needs some work. how are the multiple versions generated/uploaded? where's the code to handle them? if you're generating multiple versions, generate an mp3s so that the flash player always works. and if there's multiple version the download link should point to a page that prompts you for format.

drewish’s picture

sorry submitted this halfway through revising that first sentence. pretend that i wrote:
"well, i'm not opposed to the idea but i want to see it done right. this just seems like a tiny step towards that goal. if people really want to see it lets flush it out."

q0rban’s picture

This is indeed a tiny step IF we want the audio module itself to handle multiple codecs. However, my intention with the above patch is to let another module handle the extra codecs, while audio.module handles the rest (writing the tags, etc.).

So, in that case, yes there would be no way not to have an mp3 associated with the node, b/c the node could not have been created in the first place without it.

Does that clear it up some?

drewish’s picture

Sorry, at this point I'm pretty confused. Could you start from scratch, write up what you're trying to do, and how this change is necessary to accomplish it.

zirafa’s picture

I suggest getting in contact with Josh Koenig who used LAME for his music.module on the MusicForAmerica.org site....

q0rban’s picture

Man.. apparently i need some lessons in communication (my wife would agree)...
okay... here goes...

the 'how':
you create a node with audio.module... upload your mp3 file... then edit the node... the other module, audio_codecs (not a node module; uses nodeapi) adds a form element allowing you to upload an additional format for this audio (vorbis, flac, etc.).. the tags are then written to the new file(s) using audio_write_id3tags(), and the info is saved to an audio_codecs table (stores all the file info, such as mime_type, bitrate, sample rate, etc. etc.)

the 'why':
there are definitely advantages to different formats.. ogg acoustically is much better than mp3, with flac obviously being the best choice for audio fidelity.. at any rate... mp3 is far down on the list in terms of 'quality', so offering users different formats is a nice option to have...

the patch: the real issue with the patch is audio_write_id3tags()... as it is, there is no way to change the tagformat, which is essential when writing to different codecs.. consider the following code, adapted from getID3:

<?php

function audio_codecs_tagformats($fileformat = 'mp3') {
  switch ($fileformat) {
    case 'mp3':
    case 'mp2':
    case 'mp1':
      return array('id3v1', 'id3v2.3', 'ape');

    case 'mpc':
      return array('ape');

    case 'ogg':
      // metaflac doesn't (yet) work with OggFLAC files
      /*if ($datatype == 'flac') {
        $return = array('metaflac');
      }
      else {*/
        return array('vorbiscomment');
      // }

    case 'flac':
      return array('metaflac');

    case 'real':
      return array('real');

    default:
      return array();
  }
}

?>

the other issue with the patch is the download links (hopefully the above post explains that well enough) .. I'm not crazy about the idea of a seperate page to choose which format you want to download as... but, hey, that's debatable... what i would prefer is a list right on the node of the different codecs available for DL...

so as it is, the module reloads the body from the database, and overrides the formatting that audio.module does, adding all the codecs that are available for download in the audio-info <ul>... i'm convinced there is a better way of doing this.. but i have yet to think of it...

please tell me that all makes sense.. otherwise let's just close the issue, and i'll commit myself to an asylum...

cheers...

drewish’s picture

thanks, that makes more sense. the changes to the audio_write_id3tags() sound great, they don't break any backwards compatibility and add functionality. i'm more hesitant about the changes to audio_link(). can you think of any way to keep the current functionality and allow your other module to operate?

q0rban’s picture

StatusFileSize
new1011 bytes

i concur...

q0rban’s picture

Status: Needs work » Needs review
drewish’s picture

Status: Needs review » Reviewed & tested by the community

cool, i'll get this in when i get some time tonite.

drewish’s picture

Status: Reviewed & tested by the community » Fixed

Okay, committed the patch as well as the grammar correction from the first patch to HEAD. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)