AudibleT 0.0.1
A real-time A/B/X audio testing tool for subjective assessment of various audio parameters, compatible for general purpose computer as well as embedded systems.
|
The DatabaseManager class manages the database operations for the audio testing application. More...
#include <DatabaseManager.h>
Public Member Functions | |
DatabaseManager (QObject *parent=nullptr) | |
Constructs a new DatabaseManager object. | |
~DatabaseManager () | |
Destroys the DatabaseManager object and cleans up. | |
bool | setupDatabase () |
Sets up the database. Opens the connection and creates necessary tables. | |
void | dropAndRecreateTables () |
Drops all tables and recreates them. All data is lost. | |
bool | insertAudioFile (const QString &path, const QString &fileName) |
Inserts an audio file record into the database. | |
QList< AudioSample > | getAudioFiles () |
Retrieves all audio files from the database. | |
bool | clearAudioFiles () |
Deletes all audio files from the database. | |
int | createTestSession (int sampleId, int trialsCount) |
Creates a new test session record in the database. | |
bool | updateTestSessionEndTime (int sessionId) |
Updates the end time of a test session record in the database. | |
QVector< TestingSession > | getSessionsWithDuration () |
Retrieves all test sessions along with their durations from the database. | |
bool | insertTrial (int sessionId, const QString &correctResponse, const QString &userResponse, int responseTime) |
Inserts a new trial record into the database. | |
QVector< SessionTrial > | getTrialsForSession (int sessionId) |
Retrieves all trials for a specific session from the database. | |
double | getAverageTrialsPerSession () |
Gets the average number of trials per session. | |
double | getAverageResponseTimePerTrial () |
Gets the average response time per trial. | |
double | getAverageDurationPerSession () |
Gets the average duration per session. | |
double | getAverageSuccessPerSession () |
Gets the average success per session. | |
QMap< QString, QMap< QString, int > > | getConfusionMatrixCountsForSession (int sessionId) |
Get confusion matrix counts for a specific session. | |
QList< TestSessionData > | returnExportDataForAllSessions () |
Returns the export data for all test sessions. | |
QList< TestSessionData > | returnExportDataForSession (int sessionId) |
Returns the export data for a specific test session. | |
The DatabaseManager class manages the database operations for the audio testing application.
This class provides an interface to create, read, update, and delete data from the database. It encapsulates all the database operations and provides methods to interact with the database.
|
explicit |
Constructs a new DatabaseManager object.
parent | The parent QObject. |
bool DatabaseManager::clearAudioFiles | ( | ) |
Deletes all audio files from the database.
int DatabaseManager::createTestSession | ( | int | sampleId, |
int | trialsCount | ||
) |
Creates a new test session record in the database.
sampleId | The ID of the sample for the test session. |
trialsCount | The number of trials in the test session. |
QList< AudioSample > DatabaseManager::getAudioFiles | ( | ) |
Retrieves all audio files from the database.
double DatabaseManager::getAverageDurationPerSession | ( | ) |
Gets the average duration per session.
This method calculates and returns the average duration of sessions from the data in the database.
double DatabaseManager::getAverageResponseTimePerTrial | ( | ) |
Gets the average response time per trial.
This method calculates and returns the average response time per trial from the data in the database.
double DatabaseManager::getAverageSuccessPerSession | ( | ) |
Gets the average success per session.
This method calculates and returns the average success rate per session from the data in the database.
double DatabaseManager::getAverageTrialsPerSession | ( | ) |
Gets the average number of trials per session.
This method calculates and returns the average number of trials conducted per session in the database.
QMap< QString, QMap< QString, int > > DatabaseManager::getConfusionMatrixCountsForSession | ( | int | sessionId | ) |
Get confusion matrix counts for a specific session.
This function retrieves counts for all combinations of actual and predicted values ("A" or "B") for a specified session. The counts represent the number of instances in the session where the actual value and predicted value pair occurred.
The outer QMap has "actual" values ("A" or "B") as keys and the inner QMap as values. The inner QMap has "predicted" values ("A" or "B") as keys and counts as values.
sessionId | The ID of the session for which to retrieve the confusion matrix counts. |
QVector< TestingSession > DatabaseManager::getSessionsWithDuration | ( | ) |
Retrieves all test sessions along with their durations from the database.
QVector< SessionTrial > DatabaseManager::getTrialsForSession | ( | int | sessionId | ) |
Retrieves all trials for a specific session from the database.
sessionId | The ID of the session for which the trials are to be retrieved. |
bool DatabaseManager::insertAudioFile | ( | const QString & | path, |
const QString & | fileName | ||
) |
Inserts an audio file record into the database.
path | The path of the audio file. |
fileName | The name of the audio file. |
bool DatabaseManager::insertTrial | ( | int | sessionId, |
const QString & | correctResponse, | ||
const QString & | userResponse, | ||
int | responseTime | ||
) |
Inserts a new trial record into the database.
sessionId | The ID of the session for the trial. |
correctResponse | The correct response for the trial. |
userResponse | The user's response for the trial. |
responseTime | The time taken by the user to respond. |
QList< TestSessionData > DatabaseManager::returnExportDataForAllSessions | ( | ) |
Returns the export data for all test sessions.
This function retrieves and returns a QList<TestSessionData> containing the export data for all available test sessions.
QList< TestSessionData > DatabaseManager::returnExportDataForSession | ( | int | sessionId | ) |
Returns the export data for a specific test session.
This function retrieves and returns a QList<TestSessionData> containing the export data for the test session identified by the provided sessionId.
sessionId | The identifier of the test session to retrieve export data for. |
bool DatabaseManager::setupDatabase | ( | ) |
Sets up the database. Opens the connection and creates necessary tables.
bool DatabaseManager::updateTestSessionEndTime | ( | int | sessionId | ) |
Updates the end time of a test session record in the database.
sessionId | The ID of the session to be updated. |