Author Topic: HOW DO I Equalise volume on all recordings?  (Read 15615 times)

skeptic

  • Addicted
  • *
  • Posts: 615
    • View Profile
Re: HOW DO I Equalise volume on all recordings?
« Reply #15 on: May 11, 2009, 10:01:21 pm »
Perhaps I should have said, for all media played from lmce, not universal.  Obviously if lmce simply switches a receiver to play audio from some external device the MD is not going to be able to normalize the audio via software.  At that point you need a solution external to lmce, and of course it's going to depend on your hardware.  It's also getting pretty far off the original subject, how to get recorded videos to have roughly the same volume when played from a MD.

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: HOW DO I Equalise volume on all recordings?
« Reply #16 on: May 11, 2009, 11:55:03 pm »
Lets get back on subject.... we are not really talking about dynamic range compression (which most people with any audio knowledge at all would be appalled at if it was used to deal with varying record levels!), we are talking about a simpler issue of scaling playback volume to try and keep all media files (audio and av) at a similar level, ie compensating for the variations in record/quantisation levels.

Most standalone media players (inc Real Player, Windows Media Player, etc) have a simple function to achieve this, where they scan their media libraries, and calculate a "record level" for each piece, then store this averaged level in their database and use it to scale playback volume at play time. I have documented previously that I believe the most effective approach might be a simple 95 percentile calculation across the duration of a track to find a reasonable average whilst ignoring outliers. This could even be a standalone tool that you run at the command line, and it inserts the necessary calculated value into the media database. Then this number be used to temporarily scale the main volume level stored in AppServers Device Data during playback....

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home

chipppy

  • Veteran
  • ***
  • Posts: 65
    • View Profile
Re: HOW DO I Equalise volume on all recordings?
« Reply #18 on: May 20, 2009, 01:32:51 pm »
Hello out there people.
I have been on holidays and loved it.  Lots of sun, surf, fishing, drinking, and thoses think that we do on holidays at the beach.

Anyway.  Read through this thread and have a few things to reply.

First:  I only have RCA output so while good suggestion, not specificaly applicable to me but I will try and have a play to see if it helps.

Second:  I have since worked out that when I play a xvid the volume get adjusted down a little for some reason.  The next time I play an xvid it get adjuste down a little more, and so on until the master volume is zero.  If i play an .iso video the volume is reset and it all starts again.  Weird but interesting.

As to the original post of leveling the volume across the video ad music collections.  I like the 95%ile idea.  I have recently found that real player does a linux version.  I have not installed yet but I am going to assume that there is the same functionality in the linux version as the windozes version.
Simple questions for the developer gurus.  Can we get a copy of the source code, strip out the section that does the music leveling and modify this to do the same for the LinuxMCE music?
If yes, would it then be possible to modify to do the 95%ile thing to the video audio stream?
If yes, would it them be possible to modify so that the music and video audio streams output is the same level?
If yes, would it be possible to put in some sort of thing in the setup menu to allow a user set offset between music and video audio streams (personally I listen to music a lot louder then videos).

the reason that I ask these questions is that LinuxMCE is about home automation aswell as the music/video.  This would make the whole process automagic if the database ran a script doing this once a week or once a month in the background.  If this is possible it would be safe to assume that theming would also be possible. 
Different music level for party, general, quiet, kids going to sleep by, etc
Different audio level for different video type, actio, romantic (yuk), comadey, drama, etc
I think this is a long way off but one must set goals in order to improve oneself.

I dont even know how to do scripting so I have no ideas on the technical side but I am happy to assist where possible (throw silly ideas into the hat!

Cheers
chipppy).
ASUS P5Q SE/R, Gigabyte 8400GS - Composite TV, 4GB 1066, Intel E8500 3.15GHz dual core, 500GB HDD + 1TG HDD, Divco FusionHDVT DVB-T Digital Dual 4 TV tuner.

'Cry wolf and let slip the dogs of war'

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: HOW DO I Equalise volume on all recordings?
« Reply #19 on: May 20, 2009, 04:19:00 pm »
Some misunderstandings here - first, RCA (analogue) audio has nothing to do with the approach we are talking about in scaling volume. Analogue and digital are different in that we need to change the audio chip output volume for analogue whereas send commands to the amp to change volume levels for digital, but the principle is identical and once we are that far, that isn't the hard bit at all! The hard bit is calculating a scaling level across your media library and writing that into the database somewhere that can be accessed at playback time.

Second, jumping to a whole new media/audio player just to implement one single, tiny function is classic sledgehammer/walnut territory! No dev is going to root-and-branch rip out the entire Xine Player subsystem, and implement a whole new DCE wrapper around Real Player, just for this function ... sense of perspective please! Even if Real Player wasn't a total piece of crap (which it is) it certainly isn't open source (except the Helix bit), so its not even remotely an option.

If someone really wants a kudge solution, it would be far less effort and more supportable to 1) find a tool that could be run against the media library (possy's suggestion is a good start, but it would be far better not to modify the original files for a number of reasons, not least sound quality), and calculate a simple scaling factor, then write this into the database as a "VolumeScale" attribute, say. Then 2) modify the Media Plugin or even the Xine wrapper to read this attribute, and use it to modify the AppServer volume level, temporarily.... this would level the volume across your entire library; not impact the original media file and its quality; maintain the integrity of your last master volume settings; work across digital and analogue outputs. Although you would need to retain any volume level changes during playback and apply them at the end of playback to ensure consistent volume experience (otherwise master volume would always return to pre-playback levels irrespective of changes during playback, which would be confusing and inconvenient).

Chipppy - the experience of continuously decreasing volume levels due to xvid playbacks is not something I have ever experiences (either in digital or analogue)... it is not worth logging this as an issue for 0710 as that is end of life. But certainly something that should be logged as a ticke in Trac if you experience the same issue under 0810 beta.

chipppy

  • Veteran
  • ***
  • Posts: 65
    • View Profile
Re: HOW DO I Equalise volume on all recordings?
« Reply #20 on: May 21, 2009, 05:09:47 am »
Colin

My idea with Realplayer was not to whole scale change from one system to Realplayer but to take a small section of the source code that does the volume leveling from an existing application (possibly Realplayer or others as suggested) and 'tweak' it to work with the existing LinuxMCE application.

As to the what level to set.  I would assume (remember that I have no development skills) that there is somesort of system to calculate a magic number to use in any existing leveling coding.  eg back to my Realplayer experience, it must calculate some magic number for each track after analysing the various levels throughout the track.  (i have no idea how they do this).  I am going to assume that a music song and a video audio track are esentially the same thing, just one is a lot longer then the other.  Take (dare I mention him) Micheal Jacksons music music clips.  The song is the same on both the music clip and the song, but the music clip can be a whoile lot longer (14 minutes longer in the case of the Thriller music clip) so the fundamentals should be the same.  This is probably a good test can if someone wanted to play with it.

as to the 710 v 810*.  I am egarly awaiting the 810 final.  I dont have the skills to sort out any major problems, so at the moment I am only using final release applications.  I have only been using Linux for 6 months, but I am slowly learning.

Cheers
chipppy
ASUS P5Q SE/R, Gigabyte 8400GS - Composite TV, 4GB 1066, Intel E8500 3.15GHz dual core, 500GB HDD + 1TG HDD, Divco FusionHDVT DVB-T Digital Dual 4 TV tuner.

'Cry wolf and let slip the dogs of war'

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: HOW DO I Equalise volume on all recordings?
« Reply #21 on: May 21, 2009, 07:08:21 am »
Chipppy - as I say, Real Player is not open source, so there can be no "take a small section of the source code". Taking this from some other open source program would be a start, but there still needs to be the other pieces - taking the calculated value and storing it somewhere, then modifying the playback to use this value...

chipppy

  • Veteran
  • ***
  • Posts: 65
    • View Profile
Re: HOW DO I Equalise volume on all recordings?
« Reply #22 on: May 23, 2009, 06:52:36 am »
OK so I need to find a true open source project that have volume leveling in the source code. 
I dont know much about the 'metadata' (I think is the word for the data attached to songs that has all the details for that song).  Lets assume metadata is the right word for this post anyway.  Lets aso assume that the term 'audio track' refers to any source of audio (music, video audio, recorded noise, etc)

Can a column of metadata be setup to set the volume at the start of the audio track?
If yes then would it be possible to get the playing program to read this column first as part of setting up to play the track?

If this is possible then we could scan the database and set the 'magic level number'for the whole lot of the audio tracks.  then add in the new metadata column that sets a + or - dB  adustment to the original volume, for that specific audio track to adjust the actual output volume to be consistent with the 'magic level number'.  This means that the original metadata is not affected but the final output is.
This would give us a consistent volume start point for all audio tracks.  Lets call this the 'normalised volume'

The next step would be to then add in theming.  eg then modify 'normalised volume' by again + or - dB as per the theme volume adjustments.  As an example up the volume buy 3dB for an action movie and -3dB for a romantic movie.

How does this theory sound?  Workable?

Cheers
chipppy
ASUS P5Q SE/R, Gigabyte 8400GS - Composite TV, 4GB 1066, Intel E8500 3.15GHz dual core, 500GB HDD + 1TG HDD, Divco FusionHDVT DVB-T Digital Dual 4 TV tuner.

'Cry wolf and let slip the dogs of war'

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: HOW DO I Equalise volume on all recordings?
« Reply #23 on: May 23, 2009, 08:21:41 am »
Yes, its can be called metadata (data about data), attributes, properties, etc. Yes, a new "column" or attribute can be added to the db schema for this purpose ... your description of the approach is exactly what I described above. The hard part is finding some open source code to calculate the number....

The scaling should really just be a percentage for simplicity (0-100) to scale the present AppServer volume setting by.


EDIT: Hmm, I suppose that something could be stripped out of http://prdownloads.sourceforge.net/mp3gain/mp3gain-1_4_6-src.zip?download its Visual C++ but they appear to have made some superficial "unixifications". It seems to attempt to write a normalisation dB value into the ID3 tags of MP3 files, and is based on absolute volume targetting rather than relative to your library. The section that does the calculations would need to be isolated, and the value intercepted for our own purposes rather than modifying the ID3 tag, so it can be inserted into the database. The mpglibdbl would need to be supplimented with some other oss library to allow video streams and other audio streams to be demuxed and parsed... so still no trivial task!
« Last Edit: May 23, 2009, 08:55:52 am by colinjones »

chipppy

  • Veteran
  • ***
  • Posts: 65
    • View Profile
Re: HOW DO I Equalise volume on all recordings?
« Reply #24 on: May 23, 2009, 08:58:30 am »
I have looked at a program called MP3gain
http://sourceforge.net/projects/mp3gain/

this might be usefully, but I have no idea how to download the source code so that i can have a look through it for some clues as to what can b usefully.

I run Ubuntu 9.04.  Can you tell me how to download the source code and what to open it with and I wil have a look and see if there are any notes pointing towards anything usefull.

Cheers
chipppy
ASUS P5Q SE/R, Gigabyte 8400GS - Composite TV, 4GB 1066, Intel E8500 3.15GHz dual core, 500GB HDD + 1TG HDD, Divco FusionHDVT DVB-T Digital Dual 4 TV tuner.

'Cry wolf and let slip the dogs of war'

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: HOW DO I Equalise volume on all recordings?
« Reply #25 on: May 23, 2009, 09:28:40 am »
I have looked at a program called MP3gain
http://sourceforge.net/projects/mp3gain/

this might be usefully, but I have no idea how to download the source code so that i can have a look through it for some clues as to what can b usefully.

I run Ubuntu 9.04.  Can you tell me how to download the source code and what to open it with and I wil have a look and see if there are any notes pointing towards anything usefull.

Cheers
chipppy

Try reading my previous post, and you'll find out!

chipppy

  • Veteran
  • ***
  • Posts: 65
    • View Profile
Re: HOW DO I Equalise volume on all recordings?
« Reply #26 on: May 23, 2009, 01:34:18 pm »
Thanks for that.  I have downloaded and I will ask a mate that writes apps for the iphone to help me have a look.

cheers
chipppy
ASUS P5Q SE/R, Gigabyte 8400GS - Composite TV, 4GB 1066, Intel E8500 3.15GHz dual core, 500GB HDD + 1TG HDD, Divco FusionHDVT DVB-T Digital Dual 4 TV tuner.

'Cry wolf and let slip the dogs of war'

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: HOW DO I Equalise volume on all recordings?
« Reply #27 on: May 23, 2009, 02:11:19 pm »
Great! Make sure he reads this thread and understands the objective is to integrate the functionality with LMCE's database rather than as it is at the moment, where it writes directly into the MP3 ID3 tags. To do this, it needs to write into the pluto_main database and he can use the LMCE sql ops code to help with that. Once the schema is extended to include the new attribute, and the values written in there, UpdateMedia will write those out to the ID3 tags embedded in the MP3 files or the .id3 files associated with non-mp3 files. Then we will need someone to modify the LMCE code to read and use those values in line with what we have discussed here.

I'm still hoping someone like Thom will chime in here on that point - the reading and using part can be put in the xine wrapper but I don't think that is the right spot, it seems like a hack.... personally I think the media plugin is the right spot to keep the code less specific...