Skip to content

Commit

Permalink
[libav] Things start to settle
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Jan 23, 2024
1 parent b667fb7 commit f5c5c86
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/avendish
Submodule avendish updated 33 files
+1 −1 cmake/avendish.cmake
+2 −2 cmake/avendish.sources.cmake
+0 −1 cmake/avendish.standalone.cmake
+43 −1 cmake/avendish.vst3.cmake
+1 −0 examples/Advanced/Utilities/LightnessSampler.hpp
+1 −1 examples/Helpers/Controls.hpp
+55 −0 examples/Raw/Interpolator.hpp
+1 −4 include/avnd/binding/max/attributes_setup.hpp
+79 −3 include/avnd/binding/ossia/from_value.hpp
+4 −0 include/avnd/binding/ossia/ossia_to_curve.hpp
+2 −8 include/avnd/binding/ossia/port_run_preprocess.hpp
+41 −0 include/avnd/binding/ossia/qt.hpp
+45 −119 include/avnd/binding/standalone/oscquery_mapper.hpp
+117 −0 include/avnd/binding/standalone/oscquery_minimal_mapper.hpp
+10 −8 include/avnd/binding/standalone/prototype.cpp.in
+4 −2 include/avnd/binding/standalone/standalone.hpp
+27 −9 include/avnd/binding/ui/qml/enum_control.hpp
+1 −2 include/avnd/binding/ui/qml/enum_ui.hpp
+8 −3 include/avnd/binding/ui/qml/float_control.hpp
+0 −1 include/avnd/binding/ui/qml/float_knob.hpp
+0 −1 include/avnd/binding/ui/qml/float_slider.hpp
+8 −3 include/avnd/binding/ui/qml/int_control.hpp
+0 −1 include/avnd/binding/ui/qml/int_knob.hpp
+0 −1 include/avnd/binding/ui/qml/int_slider.hpp
+14 −3 include/avnd/binding/ui/qml/toggle_control.hpp
+8 −8 include/avnd/binding/ui/qml/toggle_ui.hpp
+27 −5 include/avnd/binding/ui/qml_layout_ui.hpp
+29 −6 include/avnd/binding/ui/qml_ui.hpp
+14 −2 include/avnd/binding/vst3/controller.hpp
+4 −1 include/avnd/binding/vst3/helpers.hpp
+58 −52 include/avnd/binding/vst3/prototype.cpp.in
+66 −20 include/avnd/introspection/widgets.hpp
+7 −0 include/avnd/wrappers/metadatas.hpp
2 changes: 1 addition & 1 deletion 3rdparty/libossia
4 changes: 1 addition & 3 deletions src/plugins/score-plugin-gfx/Gfx/Libav/AudioFrameEncoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
extern "C" {
#include <libavutil/frame.h>
}
#define SAMPLE_RATE_TEST 44100
#define BUFFER_SIZE_TEST 512

#include <ossia/dataflow/sample_to_float.hpp>

Expand All @@ -15,7 +13,7 @@ namespace Gfx

struct AudioFrameEncoder
{
AudioFrameEncoder(int target_buffer_size)
explicit AudioFrameEncoder(int target_buffer_size)
: target_buffer_size{target_buffer_size}
{
}
Expand Down
9 changes: 5 additions & 4 deletions src/plugins/score-plugin-gfx/Gfx/Libav/LibavEncoder.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "LibavEncoder.hpp"

#include "LibavOutputStream.hpp"

#include <QDebug>
extern "C" {
#include <libswresample/swresample.h>
}

#include <QDebug>

#if SCORE_HAS_LIBAV
namespace Gfx
{
Expand Down Expand Up @@ -120,9 +120,10 @@ int LibavEncoder::add_frame(tcb::span<ossia::float_vector> vec)
auto& stream = streams[audio_stream_index];
AVFrame* next_frame = stream.get_audio_frame();

next_frame->sample_rate = SAMPLE_RATE_TEST;
next_frame->sample_rate = stream.enc->sample_rate;
next_frame->format = stream.enc->sample_fmt;
next_frame->nb_samples = vec[0].size();
next_frame->nb_samples = stream.enc->frame_size;
qDebug() << vec[0].size() << next_frame->nb_samples;
next_frame->ch_layout.nb_channels = channels;
next_frame->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;

Expand Down
40 changes: 21 additions & 19 deletions src/plugins/score-plugin-gfx/Gfx/Libav/LibavOutputStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,13 @@ struct OutputStream
{
auto& audio_stgs = score::AppContext().settings<Audio::Settings::Model>();
nb_samples = audio_stgs.getBufferSize();
enc->frame_size = audio_stgs.getBufferSize();
enc->frame_size = nb_samples;
qDebug() << "Setting frame_size: " << nb_samples;
}
else
{
nb_samples = enc->frame_size;
qDebug() << "Forcing frame_size: " << nb_samples;
}
cache_input_frame = alloc_audio_frame(
enc->sample_fmt, &enc->ch_layout, enc->sample_rate, nb_samples);
Expand All @@ -245,7 +247,7 @@ struct OutputStream
{
for(int i = 0; i < set.audio_channels; i++)
this->resamplers.push_back(std::make_unique<r8b::CDSPResampler>(
SAMPLE_RATE_TEST, enc->sample_rate, nb_samples, 3.0, 206.91,
input_sample_rate, enc->sample_rate, nb_samples * 2, 3.0, 206.91,
r8b::fprMinPhase));
}

Expand Down Expand Up @@ -445,7 +447,7 @@ struct OutputStream
exit(1);

this->cache_input_frame->pts = this->next_pts;
this->next_pts += BUFFER_SIZE_TEST;
this->next_pts += this->enc->frame_size;

return this->cache_input_frame;
}
Expand Down Expand Up @@ -499,22 +501,22 @@ struct OutputStream
return ret == AVERROR_EOF ? 1 : 0;
}

#define SRC_RATE SAMPLE_RATE_TEST
#define DST_RATE SAMPLE_RATE_TEST
static int64_t conv_audio_pts(SwrContext* ctx, int64_t in, int sample_rate)
{
//int64_t d = (int64_t) AUDIO_RATE * AUDIO_RATE;
int64_t d = (int64_t)sample_rate * sample_rate;

/* Convert from audio_src_tb to 1/(src_samplerate * dst_samplerate) */
in = av_rescale_rnd(in, d, SRC_RATE, AV_ROUND_NEAR_INF);

/* In units of 1/(src_samplerate * dst_samplerate) */
in = swr_next_pts(ctx, in);

/* Convert from 1/(src_samplerate * dst_samplerate) to audio_dst_tb */
return av_rescale_rnd(in, DST_RATE, d, AV_ROUND_NEAR_INF);
}
// #define SRC_RATE SAMPLE_RATE_TEST
// #define DST_RATE SAMPLE_RATE_TEST
// static int64_t conv_audio_pts(SwrContext* ctx, int64_t in, int sample_rate)
// {
// //int64_t d = (int64_t) AUDIO_RATE * AUDIO_RATE;
// int64_t d = (int64_t)sample_rate * sample_rate;
//
// /* Convert from audio_src_tb to 1/(src_samplerate * dst_samplerate) */
// in = av_rescale_rnd(in, d, SRC_RATE, AV_ROUND_NEAR_INF);
//
// /* In units of 1/(src_samplerate * dst_samplerate) */
// in = swr_next_pts(ctx, in);
//
// /* Convert from 1/(src_samplerate * dst_samplerate) to audio_dst_tb */
// return av_rescale_rnd(in, DST_RATE, d, AV_ROUND_NEAR_INF);
// }

int write_audio_frame(AVFormatContext* fmt_ctx, AVFrame* input_frame)
{
Expand Down

0 comments on commit f5c5c86

Please sign in to comment.