Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Get BitDepth from an Audio File with QMediaPlayer

Get BitDepth from an Audio File with QMediaPlayer

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 1 Posters 909 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Darta
    wrote on last edited by Darta
    #1

    Hello everyone,

    I think everything is in the title,
    I don't know how to get Bit Depth of an Audio file with QMediaPlayer, I successfully get Audio Time, Sample Rate, Bit Rate or Channels, but I can't get the finger on Sample Size, here is my code :

    float	AudioManager::setTime(QUrl Path, QString Name,
                                  QMap<QString, int> *BitDepth,
                                  QMap<QString, int> *Rate,
                                  QMap<QString, int> *Channels,
                                  QMap<QString, int> *BitRate)
    {
    	static QMediaPlayer	*PlayerAudio = new QMediaPlayer;
    	float				time;
    	int					volume;
    
    	PlayerAudio->setMedia(QUrl::fromLocalFile(Path.toString()));
    	volume = PlayerAudio->volume();
    	PlayerAudio->setVolume(0);
    	PlayerAudio->play();
    	while (PlayerAudio->position() == 0)
    	{
    		QApplication::processEvents();
    		if (PlayerAudio->duration() > 0)
    			break;
    	}
    	PlayerAudio->stop();
    	PlayerAudio->setVolume(volume);
    	time = static_cast<float>(PlayerAudio->duration()) / 1000.0f;
    	(*BitDepth)[Name] = PlayerAudio->metaData("SampleRate").toInt() / 2000; //Absolutly not good but I don't know how to do better ...
    	(*Rate)[Name] = PlayerAudio->metaData("SampleRate").toInt();
    	(*Channels)[Name] = PlayerAudio->metaData("ChannelCount").toInt();
    	(*BitRate)[Name] = PlayerAudio->metaData("AudioBitRate").toInt() * (*Channels)[Name] / 1000;
    	return (time);
    }
    

    I know that isn't perfect but it's working, except for the sample size, I'm searching for an easy, efficient and not too long way (I have 10000 audio files to deals with) to find the sample size value.

    Hopefully someone will be able to help me !?
    Thank's by advance.

    Edit : Is it so easy that no one take time to tell me or is it just so hard that no one know ?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Darta
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • D Offline
        D Offline
        Darta
        wrote on last edited by Darta
        #3

        why there is no SampleSize here ??

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Darta
          wrote on last edited by
          #4

          Ok I found it :

          SampleSize = AudioBiteRate / SampleRate;

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved