Skip to content

Commit

Permalink
Introduced preamp, speed and pitch manipulator
Browse files Browse the repository at this point in the history
  • Loading branch information
windows-server-2003 committed Nov 28, 2021
1 parent 32f7e4e commit e1f08cc
Show file tree
Hide file tree
Showing 26 changed files with 1,878 additions and 78 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ CXXFLAGS := $(CFLAGS) -fno-exceptions -std=gnu++14
ASFLAGS := $(ARCH)
LDFLAGS = -specs=3dsx.specs $(ARCH) -Wl,-Map,$(notdir $*.map)

LIBS := -lswresample -lavformat -lswscale -lavcodec -lavutil -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -lz -lcitro2d -lcitro3d -lctru -lm
LIBS := -lavfilter -lswresample -lavformat -lswscale -lavcodec -lavutil -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -lz -lcitro2d -lcitro3d -lctru -lm

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
Expand Down
1 change: 1 addition & 0 deletions include/headers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <malloc.h>
#include <string>
#include <unistd.h>
#include <cmath>
#include <limits>
#include "citro2d.h"

Expand Down
19 changes: 19 additions & 0 deletions include/network/network_decoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
extern "C" {
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libavfilter/avfilter.h"
#include "libavfilter/buffersrc.h"
#include "libavfilter/buffersink.h"
#include "libswresample/swresample.h"
#include "libavutil/opt.h"
#include "libavutil/log.h"
}

namespace network_decoder_ {
Expand Down Expand Up @@ -99,6 +104,17 @@ public :
Result_with_string reinit();
double get_duration();
};
class NetworkDecoderFilterData {
public :
AVFilterGraph *audio_filter_graph = NULL;
AVFilterContext *audio_filter_src = NULL;
AVFilterContext *audio_filter_sink = NULL;
AVFrame *output_frame;

void deinit();
Result_with_string init(AVCodecContext *audio_context, double volume, double tempo, double pitch);
Result_with_string process_audio_frame(AVFrame *input); // filtered frame goes to output_frame. It should NOT be freed
};

class NetworkDecoder {
private :
Expand Down Expand Up @@ -137,6 +153,9 @@ public :
volatile bool need_reinit = false;
volatile bool ready = false;
double timestamp_offset = 0;
NetworkDecoderFilterData filter;

AVCodecContext *get_audio_context() { return decoder_context[AUDIO]; }
const char *get_network_waiting_status() {
if (network_stream[VIDEO] && network_stream[VIDEO]->network_waiting_status) return network_stream[VIDEO]->network_waiting_status;
if (network_stream[AUDIO] && network_stream[AUDIO]->network_waiting_status) return network_stream[AUDIO]->network_waiting_status;
Expand Down
9 changes: 9 additions & 0 deletions include/network/network_decoder_multiple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,20 @@ private :
volatile int seq_head = 0; // the latest sequence id available
volatile double duration_first_fragment = 0; // for some reason, the first fragment of a livestream differs in length from other fragments

double cur_preamp = 1.0;
double cur_tempo = 1.0;
double cur_pitch = 1.0;

void check_filter_update();
void recalc_buffered_head();
public :
volatile bool &hw_decoder_enabled = decoder.hw_decoder_enabled;
volatile bool &interrupt = decoder.interrupt;
volatile bool &need_reinit = decoder.need_reinit;
volatile const bool &ready = decoder.ready;
volatile double preamp_change_request = -1;
volatile double tempo_change_request = -1;
volatile double pitch_change_request = -1;
const char *get_network_waiting_status() { return decoder.get_network_waiting_status(); }

NetworkMultipleDecoder ();
Expand Down Expand Up @@ -102,6 +110,7 @@ public :

// decode the previously read audio packet
Result_with_string decode_audio(int *size, u8 **data, double *cur_pos) {
check_filter_update();
auto res = decoder.decode_audio(size, data, cur_pos);
return res;
}
Expand Down
2 changes: 1 addition & 1 deletion include/ui/views/bar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct BarView : public FixedSizeView {
private :
UI::FlexibleString<BarView> title;
public :
using CallBackFuncType = std::function<void (const BarView &value)>;
using CallBackFuncType = std::function<void (BarView &value)>;
BarView (double x0, double y0, double width, double height) : View(x0, y0), FixedSizeView(x0, y0, width, height) {}
virtual ~BarView () {}

Expand Down
2 changes: 1 addition & 1 deletion library/FFmpeg/FFmpeg
4 changes: 2 additions & 2 deletions library/FFmpeg/ffmpeg_build.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
The ffmpeg binaries provided in this repository have been compiled by the following configuration :

configure command :
./configure --enable-cross-compile --cross-prefix=[path_to_compiler] --prefix=[build_directory] --cpu=armv6k --arch=arm --target-os=linux --extra-cflags="-mfloat-abi=hard -mtune=mpcore -mtp=cp15" --extra-ldflags="-mfloat-abi=hard" --disable-filters --disable-devices --disable-bsfs --disable-parsers --disable-hwaccels --disable-debug --disable-programs --disable-avdevice --disable-postproc --disable-avfilter --disable-decoders --disable-demuxers --disable-encoders --disable-muxers --disable-asm --disable-protocols --enable-inline-asm --enable-vfp --enable-armv5te --enable-armv6 --enable-decoder="aac,h264,opus" --enable-demuxer="mov" --enable-protocol="file"
./configure --enable-cross-compile --cross-prefix=[path_to_compiler] --prefix=[build_directory] --cpu=armv6k --arch=arm --target-os=linux --extra-cflags="-mfloat-abi=hard -mtune=mpcore -mtp=cp15" --extra-ldflags="-mfloat-abi=hard" --disable-filters --disable-devices --disable-bsfs --disable-parsers --disable-hwaccels --disable-debug --disable-programs --disable-avdevice --disable-postproc --disable-decoders --disable-demuxers --disable-encoders --disable-muxers --disable-asm --disable-protocols --enable-inline-asm --enable-vfp --enable-armv5te --enable-armv6 --enable-filter="chorus,superequalizer,volume,asetrate,aformat,aresample,atempo,aecho,anull" --enable-decoder="aac,h264,opus" --enable-demuxer="mov" --enable-protocol="file"
An example for [path_to_compiler] and [build_directory] is "C:/devkitpro/devkitARM/bin/arm-none-eabi-" and "C:/ThirdTube/library/FFmpeg", respectively.

compiler : devkitARM release 56
hash of the commit used : 0bc7ddc460511c82392677c83bc320db26a4a06e
hash of the commit used : 4dbd7ff283d67d57e38b7c7b09668362dde05a7b (modified by QCFium)
The source code of FFmpeg used can be found in .\FFmpeg. If you find the directory empty, try running `git submodule init` and `git submodule update`.
Loading

0 comments on commit e1f08cc

Please sign in to comment.