Дмитрий
ДмитрийFeb. 28, 2019, 10:14 a.m.

Opening mp3 files using the audiere library

The audiere library allows you to work with audio files of various formats (wav, mp3, etc.). To work, we need the files audiere.h, audiere.lib, audiere.dll. h-file is included in the program code

#include "audiere.h"

lib-file is linked to .pro

LIBS += audiere.lib

dll we drag behind the program.
In RuNet it is easy to find information on how to play sound with it. But there is absolutely no information on how to get audio data for further processing. Therefore, I will write, especially since it is quite simple.


1 open file

    QString name = "D:/qtProg/audioprocessor/test2.mp3"; 
    name.replace("/","\\");
    SampleSourcePtr source;
    source = OpenSampleSource( name.toLocal8Bit() ); 
    if(!source)
    {
        ui->statusBar->showMessage("файл не открыт");
        return;
    }
    else
    {
        ui->statusBar->showMessage(name);
    }

2 read audio parameters

    int ccount; // число каналов
    int samplerate; // частота дискретизации
    SampleFormat format; // формат данных

    source->getFormat(ccount, samplerate, format);
    int l = source->getLength(); // число отсчётов одного канала

For typical audio recordings, the number of channels is two, single-channel recordings are quite common, I have not seen others, but it should work on the same principle. Note that the number of samples obtained with getLength() corresponds to one channel. Sampling frequency (if you don't know what it is, check out the Kotelnikov theorem or the Nyquist theorem). Format - determines the number of bits that encode one sample (usually 16).

3 create buffer and suitable storage

    int w = 256; // размер временного окна
    qint16 buf[w*ccount];

    QVector<qint16> data; // хранилище данных для одного канала

4 read data

    int row = l/w; // число временных фрагментов

    for(int j = 0; j < row; j++)
    {
        source->read(w, buf); // считывание фрагмента
        for(int i=0; i<w; i++)
        {
            data.append(buf[i*ccount]);
        }
    }
    source->read(w, buf); // считывание последнего фрагмента
    for(int i=0; i < l%w; i++)
    {
        data.append(buf[i*ccount]);
    }

Now the extracted data can be processed...
The text of the program can be downloaded here

We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.

Do you like it? Share on social networks!

Evgenii Legotckoi
  • Feb. 28, 2019, 3:27 p.m.
  • (edited)

Добрый день, Дмитрий.

Спасибо за статью. Единственный момент, пожалуйста, поместите статью под кат, то есть отделите большую часть статьи разделителем контента, это одна из кнопок в тулбаре редактора. Она отделяет превью статьи в ленте от остальной части контента.

Ещё раз спасибо.

i
  • Nov. 9, 2024, 8:59 p.m.

Cook meat all the way through priligy otc Note stages 2 3 AKI here exclude patients on dialysis, which are shown in a separate bar graph

Comments

Only authorized users can post comments.
Please, Log in or Sign up
AD

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:50points,
  • Rating points-4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:80points,
  • Rating points4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:20points,
  • Rating points-10
Last comments
i
innorwallNov. 12, 2024, 9:12 a.m.
Django - Tutorial 055. How to write auto populate field functionality Freckles because of several brand names retin a, atralin buy generic priligy
i
innorwallNov. 12, 2024, 5:23 a.m.
QML - Tutorial 035. Using enumerations in QML without C ++ priligy cvs 24 Together with antibiotics such as amphotericin B 10, griseofulvin 11 and streptomycin 12, chloramphenicol 9 is in the World Health Organisation s List of Essential Medici…
i
innorwallNov. 12, 2024, 2:50 a.m.
Qt/C++ - Lesson 052. Customization Qt Audio player in the style of AIMP It decreases stress, supports hormone balance, and regulates and increases blood flow to the reproductive organs buy priligy online safe Promising data were reported in a PDX model re…
i
innorwallNov. 12, 2024, 1:19 a.m.
Heap sorting algorithm The role of raloxifene in preventing breast cancer priligy precio
i
innorwallNov. 12, 2024, 12:55 a.m.
PyQt5 - Lesson 006. Work with QTableWidget buy priligy 60 mg 53 have been reported by Javanovic Santa et al
Now discuss on the forum
i
innorwallNov. 12, 2024, 7:56 a.m.
добавить qlineseries в функции buy priligy senior brother Chu He, whom he had known for many years
i
innorwallNov. 11, 2024, 9:55 p.m.
Всё ещё разбираюсь с кешем. priligy walgreens levitra dulcolax carbs The third ring was found to be made up of ultra relativistic electrons, which are also present in both the outer and inner rings
9
9AnonimOct. 25, 2024, 7:10 p.m.
Машина тьюринга // Начальное состояние 0 0, ,<,1 // Переход в состояние 1 при пустом символе 0,0,>,0 // Остаемся в состоянии 0, двигаясь вправо при встрече 0 0,1,>…

Follow us in social networks