drop libaudec dependency (and by extension libsamplerate)
This commit is contained in:
parent
b44cb7165a
commit
15d3276a9e
|
@ -71,7 +71,7 @@ tasks:
|
|||
sudo pip3 install sphinx-intl sphinx-copybutton furo sphinxcontrib-svg2pdfconverter
|
||||
pip3 install --user 'meson' --force-reinstall
|
||||
cd zrythm
|
||||
meson setup build -Dtests=true -Dmanpage=true -Db_coverage=true -Dforce_fallback_for=gtk4,libadwaita,libpanel,lilv,sord,serd,sratom,lv2,zix,libcyaml,libaudec
|
||||
meson setup build -Dtests=true -Dmanpage=true -Db_coverage=true -Dforce_fallback_for=gtk4,libadwaita,libpanel,lilv,sord,serd,sratom,lv2,zix,libcyaml
|
||||
- build: |
|
||||
cd zrythm
|
||||
ninja -C build
|
||||
|
|
|
@ -67,7 +67,7 @@ tasks:
|
|||
- setup: |
|
||||
#sudo pkg install -y py37-pip
|
||||
cd zrythm
|
||||
CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ../meson/meson.py setup build -Dtests=true -Dmanpage=true -Db_lto=false -Dforce_fallback_for=gtk4,libadwaita,libpanel,lilv,sord,serd,sratom,lv2,zix,libcyaml,libaudec
|
||||
CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ../meson/meson.py setup build -Dtests=true -Dmanpage=true -Db_lto=false -Dforce_fallback_for=gtk4,libadwaita,libpanel,lilv,sord,serd,sratom,lv2,zix,libcyaml
|
||||
- build: |
|
||||
cd zrythm
|
||||
ninja -C build
|
||||
|
|
|
@ -34,8 +34,6 @@ jobs:
|
|||
mv VERSION VERSION.txt
|
||||
gsed -i "s|'VERSION'|'VERSION.txt'|" meson.build
|
||||
meson build -Dtests=true -Dgtk4:x11-backend=false -Dx11=disabled
|
||||
mv subprojects/libaudec/VERSION subprojects/libaudec/VERSION.txt
|
||||
gsed -i "s|'VERSION'|'VERSION.txt'|" subprojects/libaudec/meson.build
|
||||
ninja -C build
|
||||
|
||||
- name: Test
|
||||
|
|
|
@ -57,9 +57,6 @@ Required
|
|||
`libadwaita (LGPLv2.1+) <https://gitlab.gnome.org/GNOME/libadwaita>`_
|
||||
Additional widgets
|
||||
|
||||
`libaudec (AGPLv3+) <https://git.zrythm.org/zrythm/libaudec/>`_
|
||||
Audio file loading
|
||||
|
||||
`libbacktrace (3-Clause BSD) <https://github.com/ianlancetaylor/libbacktrace>`_
|
||||
Backtraces
|
||||
|
||||
|
@ -74,6 +71,9 @@ Required
|
|||
|
||||
Note: if you want detach support use `our fork <https://git.sr.ht/~alextee/libpanel-detach>`_ (``zrythm_detach`` branch).
|
||||
|
||||
`libsndfile (LGPLv2.1+) <http://libsndfile.github.io/libsndfile/>`_
|
||||
Audio file IO
|
||||
|
||||
`lilv (ISC) <https://drobilla.net/software/lilv>`_
|
||||
LV2 host support
|
||||
|
||||
|
@ -86,6 +86,9 @@ Note: if you want detach support use `our fork <https://git.sr.ht/~alextee/libpa
|
|||
`rubberband (GPLv2+) <https://breakfastquay.com/rubberband/>`_
|
||||
Time-stretching and pitch-shifting
|
||||
|
||||
`soxr (LGPLv2.1+) <https://sourceforge.net/projects/soxr/>`_
|
||||
Resampling
|
||||
|
||||
`vamp-plugin-sdk (X11) <https://vamp-plugins.org/>`_
|
||||
Audio analysis
|
||||
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
// SPDX-FileCopyrightText: © 2019 Alexandros Theodotou <alex@zrythm.org>
|
||||
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Audio file info.
|
||||
*/
|
||||
|
||||
#ifndef __AUDIO_AUDIO_FILE_H__
|
||||
#define __AUDIO_AUDIO_FILE_H__
|
||||
|
||||
typedef struct SupportedFile SupportedFile;
|
||||
|
||||
/**
|
||||
* An audio file.
|
||||
*/
|
||||
typedef struct AudioFile
|
||||
{
|
||||
int channels;
|
||||
|
||||
/** Pointer to parent SupportedFile. */
|
||||
SupportedFile * file;
|
||||
} AudioFile;
|
||||
|
||||
#endif
|
|
@ -1,90 +0,0 @@
|
|||
// SPDX-FileCopyrightText: © 2019-2022 Alexandros Theodotou <alex@zrythm.org>
|
||||
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Audio file encoder.
|
||||
*/
|
||||
|
||||
#ifndef __AUDIO_ENCODER_H__
|
||||
#define __AUDIO_ENCODER_H__
|
||||
|
||||
#include "zrythm-config.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "utils/types.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <audec/audec.h>
|
||||
|
||||
/**
|
||||
* @addtogroup dsp
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Struct for holding info for encoding.
|
||||
*/
|
||||
typedef struct AudioEncoder
|
||||
{
|
||||
/** Filename, if encoding from file. */
|
||||
char * file;
|
||||
|
||||
/** Number of channels. */
|
||||
channels_t channels;
|
||||
|
||||
/** The output frames interleaved. */
|
||||
float * out_frames;
|
||||
|
||||
/** Output number of frames per channel. */
|
||||
unsigned_frame_t num_out_frames;
|
||||
|
||||
AudecInfo nfo;
|
||||
AudecHandle * audec_handle;
|
||||
} AudioEncoder;
|
||||
|
||||
/**
|
||||
* Creates a new instance of an AudioEncoder from
|
||||
* the given file, that can be used for encoding.
|
||||
*
|
||||
* It converts the file into a float array in its
|
||||
* original sample rate and prepares the instance
|
||||
* for decoding it into the project's sample rate.
|
||||
*/
|
||||
AudioEncoder *
|
||||
audio_encoder_new_from_file (
|
||||
const char * filepath,
|
||||
GError ** error);
|
||||
|
||||
/**
|
||||
* Decodes the information in the AudioEncoder
|
||||
* instance and stores the results there.
|
||||
*
|
||||
* Resamples the input float array to match the
|
||||
* project's sample rate.
|
||||
*
|
||||
* Assumes that the input array is already filled in.
|
||||
*
|
||||
* @param show_progress Display a progress dialog.
|
||||
*/
|
||||
NONNULL void
|
||||
audio_encoder_decode (
|
||||
AudioEncoder * self,
|
||||
int samplerate,
|
||||
bool show_progress);
|
||||
|
||||
/**
|
||||
* Free's the AudioEncoder and its members.
|
||||
*/
|
||||
NONNULL void
|
||||
audio_encoder_free (AudioEncoder * self);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif
|
|
@ -1,21 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2021 Alexandros Theodotou <alex at zrythm dot org>
|
||||
*
|
||||
* This file is part of Zrythm
|
||||
*
|
||||
* Zrythm is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Zrythm is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Zrythm. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-FileCopyrightText: © 2019-2021 Alexandros Theodotou <alex@zrythm.org>
|
||||
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
|
||||
|
||||
/**
|
||||
* \file
|
||||
|
|
|
@ -60,14 +60,6 @@ typedef struct AudioFile
|
|||
|
||||
/** Implemented in the source file. */
|
||||
void * internal_data;
|
||||
|
||||
#if 0
|
||||
/** The output frames interleaved. */
|
||||
float * out_frames;
|
||||
|
||||
/** Output number of frames per channel. */
|
||||
unsigned_frame_t num_out_frames;
|
||||
#endif
|
||||
} AudioFile;
|
||||
|
||||
/**
|
||||
|
@ -92,9 +84,9 @@ bool audio_file_read_metadata (
|
|||
* @param samples Samples to fill in.
|
||||
* @param in_parts Whether to read the file in parts. If true,
|
||||
* @p start_from and @p num_frames_to_read must be specified.
|
||||
* @param samples Pre-allocated frame array. Caller must ensure
|
||||
* there is enough space (ie, number of frames * number of
|
||||
* channels).
|
||||
* @param samples[out] Pre-allocated frame array. Caller must
|
||||
* ensure there is enough space (ie, number of frames *
|
||||
* number of channels).
|
||||
*/
|
||||
NONNULL_ARGS (1)
|
||||
bool audio_file_read_samples (
|
||||
|
@ -108,10 +100,34 @@ bool audio_file_read_samples (
|
|||
/**
|
||||
* Must be called when done reading or writing files (or when
|
||||
* the operation was cancelled).
|
||||
*
|
||||
* This is not needed when only reading metadata.
|
||||
*/
|
||||
NONNULL_ARGS (1)
|
||||
bool audio_file_finish (AudioFile * self, GError ** error);
|
||||
|
||||
/**
|
||||
* Simple blocking API for reading and optionally resampling
|
||||
* audio files.
|
||||
*
|
||||
* Only to be used on small files.
|
||||
*
|
||||
* @param[out] frames Pointer to store newly allocated
|
||||
* interlaved frames to.
|
||||
* @param[out] metadata File metadata will be pasted here if
|
||||
* non-NULL.
|
||||
* @param samplerate If specified, the audio will be resampled
|
||||
* to the given samplerate. Pass 0 to avoid resampling.
|
||||
*/
|
||||
bool
|
||||
audio_file_read_simple (
|
||||
const char * filepath,
|
||||
float ** frames,
|
||||
size_t * num_frames,
|
||||
AudioFileMetadata * metadata,
|
||||
size_t samplerate,
|
||||
GError ** error);
|
||||
|
||||
NONNULL void
|
||||
audio_file_free (AudioFile * self);
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
#include "utils/types.h"
|
||||
#include "utils/yaml.h"
|
||||
|
||||
#include <audec/audec.h>
|
||||
|
||||
/**
|
||||
* @addtogroup utils
|
||||
*
|
||||
|
@ -83,12 +81,6 @@ audio_bit_depth_to_pretty_str (BitDepth depth);
|
|||
*/
|
||||
#define STRIP_SIZE 9
|
||||
|
||||
void
|
||||
audio_audec_log_func (
|
||||
AudecLogLevel level,
|
||||
const char * fmt,
|
||||
va_list args) G_GNUC_PRINTF (2, 0);
|
||||
|
||||
/**
|
||||
* Writes the buffer as a raw file to the given path.
|
||||
*
|
||||
|
|
|
@ -842,13 +842,6 @@ sndfile_dep = dependency (
|
|||
'programs=false',
|
||||
'default_library=static',
|
||||
])
|
||||
audec_dep = dependency(
|
||||
'audec', version: '>=0.3.2',
|
||||
fallback: ['libaudec', 'libaudec_dep'],
|
||||
static: all_static,
|
||||
default_options: [
|
||||
'default_library=static',
|
||||
])
|
||||
soxr_dep = dependency('soxr')
|
||||
|
||||
# link to fontconfig/pangoft2 directly because
|
||||
|
@ -1275,7 +1268,6 @@ zrythm_deps = [
|
|||
pulseaudio_dep,
|
||||
libsoundio_dep,
|
||||
cyaml_dep,
|
||||
audec_dep,
|
||||
soxr_dep,
|
||||
libcgraph_dep,
|
||||
libgvc_dep,
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
// SPDX-FileCopyrightText: © 2019-2022 Alexandros Theodotou <alex@zrythm.org>
|
||||
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
|
||||
|
||||
#include "zrythm-config.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "dsp/encoder.h"
|
||||
#include "dsp/engine.h"
|
||||
#include "project.h"
|
||||
#include "utils/objects.h"
|
||||
#include "zrythm_app.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Z_AUDIO_ENCODER_ERROR_FAILED,
|
||||
} ZAudioEncoderError;
|
||||
|
||||
#define Z_AUDIO_ENCODER_ERROR z_audio_encoder_error_quark ()
|
||||
GQuark
|
||||
z_audio_encoder_error_quark (void);
|
||||
G_DEFINE_QUARK (
|
||||
z - audio - encoder - error - quark,
|
||||
z_audio_encoder_error)
|
||||
|
||||
/**
|
||||
* Creates a new instance of an AudioEncoder from
|
||||
* the given file, that can be used for encoding.
|
||||
*
|
||||
* It converts the file into a float array in its
|
||||
* original sample rate and prepares the instance
|
||||
* for decoding it into the project's sample rate.
|
||||
*/
|
||||
AudioEncoder *
|
||||
audio_encoder_new_from_file (
|
||||
const char * filepath,
|
||||
GError ** error)
|
||||
{
|
||||
AudioEncoder * self = object_new (AudioEncoder);
|
||||
|
||||
audec_set_log_level (AUDEC_LOG_LEVEL_DEBUG);
|
||||
audec_set_log_func (audio_audec_log_func);
|
||||
|
||||
/* read info */
|
||||
self->audec_handle = audec_open (filepath, &self->nfo);
|
||||
if (!self->audec_handle)
|
||||
{
|
||||
g_set_error (
|
||||
error, Z_AUDIO_ENCODER_ERROR,
|
||||
Z_AUDIO_ENCODER_ERROR_FAILED,
|
||||
_ ("An error has occurred opening the audio file '%s'"),
|
||||
filepath);
|
||||
free (self);
|
||||
return NULL;
|
||||
}
|
||||
self->file = g_strdup (filepath);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the information in the AudioEncoder
|
||||
* instance and stores the results there.
|
||||
*
|
||||
* Resamples the input float array to match the
|
||||
* project's sample rate.
|
||||
*
|
||||
* Assumes that the input array is already filled in.
|
||||
*
|
||||
* @param show_progress Display a progress dialog.
|
||||
*/
|
||||
void
|
||||
audio_encoder_decode (
|
||||
AudioEncoder * self,
|
||||
int samplerate,
|
||||
bool show_progress)
|
||||
{
|
||||
g_message ("--audio decoding start %s--", self->file);
|
||||
|
||||
g_debug (
|
||||
"source file samplerate: %u", self->nfo.sample_rate);
|
||||
|
||||
self->out_frames = NULL;
|
||||
ssize_t num_out_frames = audec_read (
|
||||
self->audec_handle, &self->out_frames, samplerate);
|
||||
if (num_out_frames < 0)
|
||||
{
|
||||
g_critical (
|
||||
"An error has occurred during reading of "
|
||||
"the audio file %s",
|
||||
self->file);
|
||||
}
|
||||
self->num_out_frames = (unsigned_frame_t) num_out_frames;
|
||||
g_message ("num out frames %" PRIu64, self->num_out_frames);
|
||||
self->channels = self->nfo.channels;
|
||||
audec_close (self->audec_handle);
|
||||
g_message ("--audio decoding end %s--", self->file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Free's the AudioEncoder and its members.
|
||||
*/
|
||||
void
|
||||
audio_encoder_free (AudioEncoder * self)
|
||||
{
|
||||
if (self->out_frames)
|
||||
free (self->out_frames);
|
||||
if (self->file)
|
||||
g_free (self->file);
|
||||
|
||||
free (self);
|
||||
}
|
|
@ -25,7 +25,6 @@ audio_srcs = files([
|
|||
'control_room.c',
|
||||
'curve.c',
|
||||
'ditherer.c',
|
||||
'encoder.c',
|
||||
'engine.c',
|
||||
'engine_alsa.c',
|
||||
'engine_dummy.c',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// SPDX-FileCopyrightText: © 2019-2022 Alexandros Theodotou <alex@zrythm.org>
|
||||
// SPDX-FileCopyrightText: © 2019-2023 Alexandros Theodotou <alex@zrythm.org>
|
||||
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
|
||||
|
||||
#include "zrythm-config.h"
|
||||
|
@ -6,16 +6,17 @@
|
|||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "dsp/encoder.h"
|
||||
#include "dsp/engine.h"
|
||||
#include "dsp/metronome.h"
|
||||
#include "dsp/position.h"
|
||||
#include "dsp/transport.h"
|
||||
#include "io/audio_file.h"
|
||||
#include "project.h"
|
||||
#include "settings/settings.h"
|
||||
#include "utils/audio.h"
|
||||
#include "utils/debug.h"
|
||||
#include "utils/dsp.h"
|
||||
#include "utils/error.h"
|
||||
#include "utils/flags.h"
|
||||
#include "utils/io.h"
|
||||
#include "utils/objects.h"
|
||||
|
@ -53,64 +54,35 @@ metronome_new (void)
|
|||
samplesdir, "square_normal.wav", NULL);
|
||||
}
|
||||
|
||||
/* decode */
|
||||
AudioEncoder * enc =
|
||||
audio_encoder_new_from_file (self->emphasis_path, NULL);
|
||||
if (!enc)
|
||||
GError * err = NULL;
|
||||
AudioFileMetadata metadata = { 0 };
|
||||
bool success = audio_file_read_simple (
|
||||
self->emphasis_path, &self->emphasis, &self->emphasis_size,
|
||||
&metadata, AUDIO_ENGINE->sample_rate, &err);
|
||||
if (!success)
|
||||
{
|
||||
g_critical (
|
||||
"Failed to load samples for metronome "
|
||||
"from %s",
|
||||
HANDLE_ERROR (
|
||||
err, "Failed to load samples for metronome from %s",
|
||||
self->emphasis_path);
|
||||
metronome_free (self);
|
||||
return NULL;
|
||||
}
|
||||
audio_encoder_decode (
|
||||
enc, (int) AUDIO_ENGINE->sample_rate, F_NO_SHOW_PROGRESS);
|
||||
self->emphasis = object_new_n (
|
||||
(size_t) (enc->num_out_frames * enc->channels), float);
|
||||
self->emphasis_size = enc->num_out_frames;
|
||||
self->emphasis_channels = enc->channels;
|
||||
if (enc->channels <= 0)
|
||||
{
|
||||
g_critical ("channels: %d", enc->channels);
|
||||
audio_encoder_free (enc);
|
||||
metronome_free (self);
|
||||
return NULL;
|
||||
}
|
||||
self->emphasis_channels = (channels_t) metadata.channels;
|
||||
|
||||
dsp_copy (
|
||||
self->emphasis, enc->out_frames,
|
||||
(size_t) enc->num_out_frames * (size_t) enc->channels);
|
||||
audio_encoder_free (enc);
|
||||
|
||||
enc = audio_encoder_new_from_file (self->normal_path, NULL);
|
||||
if (!enc)
|
||||
err = NULL;
|
||||
memset (&metadata, 0, sizeof (AudioFileMetadata));
|
||||
success = audio_file_read_simple (
|
||||
self->normal_path, &self->normal, &self->normal_size,
|
||||
&metadata, AUDIO_ENGINE->sample_rate, &err);
|
||||
if (!success)
|
||||
{
|
||||
g_critical (
|
||||
"Failed to load samples for metronome "
|
||||
"from %s",
|
||||
HANDLE_ERROR (
|
||||
err, "Failed to load samples for metronome from %s",
|
||||
self->normal_path);
|
||||
metronome_free (self);
|
||||
return NULL;
|
||||
}
|
||||
audio_encoder_decode (
|
||||
enc, (int) AUDIO_ENGINE->sample_rate, F_NO_SHOW_PROGRESS);
|
||||
self->normal = object_new_n (
|
||||
(size_t) (enc->num_out_frames * enc->channels), float);
|
||||
self->normal_size = enc->num_out_frames;
|
||||
self->normal_channels = enc->channels;
|
||||
if (enc->channels <= 0)
|
||||
{
|
||||
g_critical ("channels: %d", enc->channels);
|
||||
audio_encoder_free (enc);
|
||||
metronome_free (self);
|
||||
return NULL;
|
||||
}
|
||||
dsp_copy (
|
||||
self->normal, enc->out_frames,
|
||||
(size_t) enc->num_out_frames * (size_t) enc->channels);
|
||||
audio_encoder_free (enc);
|
||||
self->normal_channels = (channels_t) metadata.channels;
|
||||
|
||||
/* set volume */
|
||||
self->volume =
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "dsp/encoder.h"
|
||||
#include "dsp/supported_file.h"
|
||||
#include "io/audio_file.h"
|
||||
#include "utils/error.h"
|
||||
#include "utils/io.h"
|
||||
#include "utils/objects.h"
|
||||
#include "utils/string.h"
|
||||
|
@ -234,16 +235,23 @@ supported_file_should_autoplay (const SupportedFile * self)
|
|||
|
||||
if (supported_file_type_is_audio (self->type))
|
||||
{
|
||||
AudioEncoder * enc =
|
||||
audio_encoder_new_from_file (self->abs_path, NULL);
|
||||
if (!enc)
|
||||
return false;
|
||||
AudioFile * af = audio_file_new (self->abs_path);
|
||||
GError * err = NULL;
|
||||
bool success = audio_file_read_metadata (af, &err);
|
||||
if (!success)
|
||||
{
|
||||
HANDLE_ERROR (
|
||||
err, "Error reading metadata from %s",
|
||||
af->filepath);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((enc->nfo.length / 1000) > 60)
|
||||
if ((af->metadata.length / 1000) > 60)
|
||||
{
|
||||
autoplay = false;
|
||||
}
|
||||
audio_encoder_free (enc);
|
||||
|
||||
audio_file_free (af);
|
||||
}
|
||||
|
||||
return autoplay;
|
||||
|
@ -261,12 +269,18 @@ supported_file_get_info_text_for_label (
|
|||
char * label = NULL;
|
||||
if (supported_file_type_is_audio (self->type))
|
||||
{
|
||||
AudioEncoder * enc =
|
||||
audio_encoder_new_from_file (self->abs_path, NULL);
|
||||
if (!enc)
|
||||
AudioFile * af = audio_file_new (self->abs_path);
|
||||
GError * err = NULL;
|
||||
bool success = audio_file_read_metadata (af, &err);
|
||||
if (!success)
|
||||
{
|
||||
HANDLE_ERROR (
|
||||
err, "Error reading metadata from %s",
|
||||
af->filepath);
|
||||
g_free (file_type_label);
|
||||
return g_strdup (_ ("Failed opening file"));
|
||||
return g_strdup_printf (
|
||||
_ ("Failed reading metadata for %s"),
|
||||
af->filepath);
|
||||
}
|
||||
|
||||
label = g_markup_printf_escaped (
|
||||
|
@ -277,12 +291,14 @@ supported_file_get_info_text_for_label (
|
|||
"%" PRId64 " ms | BPM: %.1f\n"
|
||||
"Channel(s): %u | Bitrate: %'d.%d kb/s\n"
|
||||
"Bit depth: %d bits"),
|
||||
self->label, enc->nfo.sample_rate,
|
||||
enc->nfo.length / 1000, enc->nfo.length % 1000,
|
||||
(double) enc->nfo.bpm, enc->nfo.channels,
|
||||
enc->nfo.bit_rate / 1000,
|
||||
(enc->nfo.bit_rate % 1000) / 100, enc->nfo.bit_depth);
|
||||
audio_encoder_free (enc);
|
||||
self->label, af->metadata.samplerate,
|
||||
af->metadata.length / 1000,
|
||||
af->metadata.length % 1000, (double) af->metadata.bpm,
|
||||
af->metadata.channels, af->metadata.bit_rate / 1000,
|
||||
(af->metadata.bit_rate % 1000) / 100,
|
||||
af->metadata.bit_depth);
|
||||
|
||||
audio_file_free (af);
|
||||
}
|
||||
else
|
||||
label = g_markup_printf_escaped (
|
||||
|
|
|
@ -33,8 +33,6 @@
|
|||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <audec/audec.h>
|
||||
|
||||
G_DEFINE_TYPE (
|
||||
FileBrowserWidget,
|
||||
file_browser_widget,
|
||||
|
|
|
@ -31,8 +31,11 @@
|
|||
#include <inttypes.h>
|
||||
|
||||
#include "io/audio_file.h"
|
||||
#include "utils/debug.h"
|
||||
#include "utils/dsp.h"
|
||||
#include "utils/error.h"
|
||||
#include "utils/objects.h"
|
||||
#include "utils/resampler.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
|
@ -217,9 +220,9 @@ audio_file_read_metadata (AudioFile * self, GError ** error)
|
|||
* @param samples Samples to fill in.
|
||||
* @param in_parts Whether to read the file in parts. If true,
|
||||
* @p start_from and @p num_frames_to_read must be specified.
|
||||
* @param samples Pre-allocated frame array. Caller must ensure
|
||||
* there is enough space (ie, number of frames * number of
|
||||
* channels).
|
||||
* @param samples[out] Pre-allocated frame array. Caller must
|
||||
* ensure there is enough space (ie, number of frames *
|
||||
* number of channels).
|
||||
*/
|
||||
bool
|
||||
audio_file_read_samples (
|
||||
|
@ -321,6 +324,110 @@ audio_file_finish (AudioFile * self, GError ** error)
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple blocking API for reading and optionally resampling
|
||||
* audio files.
|
||||
*
|
||||
* Only to be used on small files.
|
||||
*
|
||||
* @param[out] frames Pointer to store newly allocated
|
||||
* interlaved frames to.
|
||||
* @param[out] metadata File metadata will be pasted here if
|
||||
* non-NULL.
|
||||
* @param samplerate If specified, the audio will be resampled
|
||||
* to the given samplerate. Pass 0 to avoid resampling.
|
||||
*/
|
||||
bool
|
||||
audio_file_read_simple (
|
||||
const char * filepath,
|
||||
float ** frames,
|
||||
size_t * num_frames,
|
||||
AudioFileMetadata * metadata,
|
||||
size_t samplerate,
|
||||
GError ** error)
|
||||
{
|
||||
g_return_val_if_fail (filepath, false);
|
||||
g_return_val_if_fail (frames, false);
|
||||
g_return_val_if_fail (num_frames, false);
|
||||
|
||||
/* read metadata */
|
||||
AudioFile * af = audio_file_new (filepath);
|
||||
GError * err = NULL;
|
||||
bool success = audio_file_read_metadata (af, &err);
|
||||
if (!success)
|
||||
{
|
||||
PROPAGATE_PREFIXED_ERROR (
|
||||
error, err, "Error reading metadata from %s",
|
||||
filepath);
|
||||
return false;
|
||||
}
|
||||
if (metadata)
|
||||
{
|
||||
*metadata = af->metadata;
|
||||
}
|
||||
|
||||
/* read frames in file's sample rate */
|
||||
z_return_val_if_fail_cmp (
|
||||
af->metadata.num_frames, >=, 0, false);
|
||||
z_return_val_if_fail_cmp (
|
||||
af->metadata.channels, >, 0, false);
|
||||
size_t arr_size =
|
||||
(size_t) af->metadata.num_frames
|
||||
* (size_t) af->metadata.channels;
|
||||
*frames = g_realloc (*frames, arr_size * sizeof (float));
|
||||
success = audio_file_read_samples (
|
||||
af, false, *frames, 0, (size_t) af->metadata.num_frames,
|
||||
&err);
|
||||
if (!success)
|
||||
{
|
||||
PROPAGATE_PREFIXED_ERROR (
|
||||
error, err, "Error reading frames from %s", filepath);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (samplerate != 0)
|
||||
{
|
||||
/* resample to project's sample rate */
|
||||
Resampler * r = resampler_new (
|
||||
*frames, (size_t) af->metadata.num_frames,
|
||||
af->metadata.samplerate, samplerate,
|
||||
(unsigned int) af->metadata.channels,
|
||||
RESAMPLER_QUALITY_VERY_HIGH, &err);
|
||||
if (!r)
|
||||
{
|
||||
PROPAGATE_PREFIXED_ERROR_LITERAL (
|
||||
error, err, "Failed to create resampler");
|
||||
return false;
|
||||
}
|
||||
while (!resampler_is_done (r))
|
||||
{
|
||||
success = resampler_process (r, &err);
|
||||
if (!success)
|
||||
{
|
||||
PROPAGATE_PREFIXED_ERROR_LITERAL (
|
||||
error, err, "Resampler failed to process");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*num_frames = r->num_out_frames;
|
||||
arr_size = *num_frames * (size_t) af->metadata.channels;
|
||||
*frames = g_realloc (*frames, arr_size * sizeof (float));
|
||||
dsp_copy (*frames, r->out_frames, arr_size);
|
||||
object_free_w_func_and_null (resampler_free, r);
|
||||
}
|
||||
|
||||
success = audio_file_finish (af, &err);
|
||||
if (!success)
|
||||
{
|
||||
PROPAGATE_PREFIXED_ERROR_LITERAL (
|
||||
error, err, "Failed to finish audio file usage");
|
||||
return false;
|
||||
}
|
||||
object_free_w_func_and_null (audio_file_free, af);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
audio_file_free (AudioFile * self)
|
||||
{
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include <audec/audec.h>
|
||||
#include <sndfile.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -60,39 +59,6 @@ audio_bit_depth_to_pretty_str (BitDepth depth)
|
|||
return _ (bit_depth_pretty_strings[depth]);
|
||||
}
|
||||
|
||||
void
|
||||
audio_audec_log_func (
|
||||
AudecLogLevel level,
|
||||
const char * fmt,
|
||||
va_list args)
|
||||
{
|
||||
GLogLevelFlags g_level = G_LOG_LEVEL_MESSAGE;
|
||||
switch (level)
|
||||
{
|
||||
case AUDEC_LOG_LEVEL_ERROR:
|
||||
g_level = G_LOG_LEVEL_CRITICAL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*char format[9000];*/
|
||||
/*strcpy (format, fmt);*/
|
||||
/*format[strlen (format) - 1] = '\0';*/
|
||||
|
||||
if (ZRYTHM_TESTING)
|
||||
{
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
g_message (fmt, args);
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
else
|
||||
{
|
||||
g_logv ("audec", g_level, fmt, args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the buffer as a raw file to the given path.
|
||||
*
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
# include <glib.h>
|
||||
|
||||
# include <audec/audec.h>
|
||||
# include <sndfile.h>
|
||||
|
||||
void
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
|
||||
|
||||
#include "utils/audio.h"
|
||||
#include "utils/math.h"
|
||||
#include "utils/objects.h"
|
||||
#include "utils/resampler.h"
|
||||
|
||||
|
|
|
@ -90,7 +90,6 @@
|
|||
|
||||
#include "Wrapper.h"
|
||||
#include "ext/whereami/whereami.h"
|
||||
#include <audec/audec.h>
|
||||
#include <fftw3.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <gtksourceview/gtksource.h>
|
||||
|
@ -1068,10 +1067,6 @@ zrythm_app_startup (GApplication * app)
|
|||
fftw_make_planner_thread_safe ();
|
||||
fftwf_make_planner_thread_safe ();
|
||||
|
||||
/* init audio decoder */
|
||||
g_message ("Initing audio decoder...");
|
||||
audec_init ();
|
||||
|
||||
#ifdef HAVE_LSP_DSP
|
||||
/* init lsp dsp */
|
||||
g_message ("Initing LSP DSP...");
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[wrap-git]
|
||||
url = https://git.sr.ht/~alextee/libaudec
|
||||
revision = master
|
|
@ -4,7 +4,6 @@
|
|||
#include "zrythm-test-config.h"
|
||||
|
||||
#include "actions/tracklist_selections.h"
|
||||
#include "dsp/encoder.h"
|
||||
#include "dsp/exporter.h"
|
||||
#include "dsp/supported_file.h"
|
||||
#include "project.h"
|
||||
|
|
20
tools/vg.sup
20
tools/vg.sup
|
@ -100,26 +100,6 @@
|
|||
...
|
||||
}
|
||||
|
||||
{
|
||||
audec_log_uninitialized_val
|
||||
Memcheck:Value8
|
||||
...
|
||||
fun:g_strdup_vprintf
|
||||
fun:g_log_structured_standard
|
||||
fun:audio_audec_log_func
|
||||
...
|
||||
}
|
||||
|
||||
{
|
||||
audec_log_jump_depending_on_uninitialized_val
|
||||
Memcheck:Cond
|
||||
...
|
||||
fun:g_strdup_vprintf
|
||||
fun:g_log_structured_standard
|
||||
fun:audio_audec_log_func
|
||||
...
|
||||
}
|
||||
|
||||
{
|
||||
helm_lv2_instantiation
|
||||
Memcheck:Cond
|
||||
|
|
Loading…
Reference in New Issue