From 526b30c5c971faa18c0ab25a6899123c707cc385 Mon Sep 17 00:00:00 2001 From: Ricardo Garcia Date: Fri, 13 Oct 2023 01:15:06 +0000 Subject: Upgrade sonic to 8694c596378c24e340c09ff2cd47c065494233f1 This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update sonic For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md Test: TreeHugger Change-Id: Ifab9d5226755a71ad84973f652b956f27d8a8176 --- METADATA | 8 ++++---- Makefile | 16 +++++++++++++--- sonic.c | 17 ++++++++++------- sonic.h | 8 +++++++- spectrogram.c | 9 ++------- wave.c | 2 +- 6 files changed, 37 insertions(+), 23 deletions(-) diff --git a/METADATA b/METADATA index a800c58..df77656 100644 --- a/METADATA +++ b/METADATA @@ -7,13 +7,13 @@ description: "Sonic is a simple algorithm for speeding up or slowing down speech third_party { url { type: ARCHIVE - value: "https://github.com/waywardgeek/sonic/archive/9a8d05dc0baa9159fc322dd9905a04e23b161337.zip" + value: "https://github.com/waywardgeek/sonic/archive/8694c596378c24e340c09ff2cd47c065494233f1.zip" } - version: "9a8d05dc0baa9159fc322dd9905a04e23b161337" + version: "8694c596378c24e340c09ff2cd47c065494233f1" license_type: NOTICE last_upgrade_date { year: 2023 - month: 9 - day: 9 + month: 10 + day: 13 } } diff --git a/Makefile b/Makefile index 2f7fd60..5e99ad1 100644 --- a/Makefile +++ b/Makefile @@ -81,7 +81,7 @@ sonic.o: sonic.c sonic.h # Define a version of sonic with the internal names defined so others (i.e. Speedy) # can build new APIs that superscede the default API. sonic_internal.o: sonic.c sonic.h - $(CC) $(CPPFLAGS) $(CFLAGS) -DSONIC_INTERNAL -DSONIC_SPECTROGRAM -c sonic.c -o sonic_internal.o + $(CC) $(CPPFLAGS) $(CFLAGS) -DSONIC_INTERNAL -c sonic.c -o sonic_internal.o wave.o: wave.c wave.h $(CC) $(CPPFLAGS) $(CFLAGS) -c wave.c @@ -99,8 +99,8 @@ ifneq ($(UNAME), Darwin) ln -sf $(LIB_NAME)$(LIB_TAG) $(LIB_NAME).0 endif -$(LIB_INTERNAL_NAME)$(LIB_TAG): $(EXTRA_OBJ) sonic_internal.o spectrogram.o wave.o - $(CC) $(CFLAGS) $(LDFLAGS) $(SHARED_OPT) -Wl,$(SONAME)$(LIB_INTERNAL_NAME) $(EXTRA_OBJ) sonic_internal.o spectrogram.o -o $(LIB_INTERNAL_NAME)$(LIB_TAG) $(FFTLIB) wave.o +$(LIB_INTERNAL_NAME)$(LIB_TAG): $(EXTRA_OBJ) sonic_internal.o wave.o # No spectrogram needed here. + $(CC) $(CFLAGS) $(LDFLAGS) $(SHARED_OPT) -Wl,$(SONAME)$(LIB_INTERNAL_NAME) $(EXTRA_OBJ) sonic_internal.o -o $(LIB_INTERNAL_NAME)$(LIB_TAG) $(FFTLIB) wave.o ifneq ($(UNAME), Darwin) ln -sf $(LIB_INTERNAL_NAME)$(LIB_TAG) $(LIB_INTERNAL_NAME) ln -sf $(LIB_INTERNAL_NAME)$(LIB_TAG) $(LIB_INTERNAL_NAME).0 @@ -138,3 +138,13 @@ clean: check: ./sonic -s 2.0 ./samples/talking.wav ./test.wav + + +libspeedy.so: + cd speedy; make libspeedy.so SONIC_DIR=.. FFTW_DIR=../../fftw + +speedy_wave: libsonic_internal.so + cd speedy; make speedy_wave SONIC_DIR=.. FFTW_DIR=../../fftw + # You will probably also need to set the LDPATH. For example + # export LD_LIBRARY_PATH=/usr/local/lib:../kissfft:speedy:. + diff --git a/sonic.c b/sonic.c index c18fc6e..d04f015 100644 --- a/sonic.c +++ b/sonic.c @@ -235,8 +235,6 @@ struct sonicStreamStruct { int prevMinDiff; }; -#ifdef SONIC_SPECTROGRAM - /* Attach user data to the stream. */ void sonicSetUserData(sonicStream stream, void *userData) { stream->userData = userData; @@ -247,6 +245,8 @@ void *sonicGetUserData(sonicStream stream) { return stream->userData; } +#ifdef SONIC_SPECTROGRAM + /* Compute a spectrogram on the fly. */ void sonicComputeSpectrogram(sonicStream stream) { stream->spectrogram = sonicCreateSpectrogram(stream->sampleRate); @@ -391,7 +391,7 @@ static int allocateStreamBuffers(sonicStream stream, int sampleRate, /* Allocate 25% more than needed so we hopefully won't grow. */ stream->pitchBufferSize = maxRequired + (maxRequired >> 2); stream->pitchBuffer = - (short*)sonicCalloc(stream->pitchBufferSize, sizeof(short) * numChannels); + (short*)sonicCalloc(maxRequired, sizeof(short) * numChannels); if (stream->pitchBuffer == NULL) { sonicDestroyStream(stream); return 0; @@ -887,12 +887,15 @@ static int moveNewSamplesToPitchBuffer(sonicStream stream, int originalNumOutputSamples) { int numSamples = stream->numOutputSamples - originalNumOutputSamples; int numChannels = stream->numChannels; - int pitchBufferSize = stream->pitchBufferSize; - if (stream->numPitchSamples + numSamples > pitchBufferSize) { + if (stream->numPitchSamples + numSamples > stream->pitchBufferSize) { + int pitchBufferSize = stream->pitchBufferSize; stream->pitchBufferSize += (pitchBufferSize >> 1) + numSamples; - stream->pitchBuffer = (short*)sonicRealloc(stream->pitchBuffer, - pitchBufferSize, stream->pitchBufferSize, sizeof(short) * numChannels); + stream->pitchBuffer = (short*)sonicRealloc( + stream->pitchBuffer, + pitchBufferSize, + stream->pitchBufferSize, + sizeof(short) * numChannels); } memcpy(stream->pitchBuffer + stream->numPitchSamples * numChannels, stream->outputBuffer + originalNumOutputSamples * numChannels, diff --git a/sonic.h b/sonic.h index ea439b0..f393dce 100644 --- a/sonic.h +++ b/sonic.h @@ -1,3 +1,6 @@ +#ifndef SONIC_H_ +#define SONIC_H_ + /* Sonic library Copyright 2010 Bill Cox @@ -57,7 +60,7 @@ extern "C" { #ifdef SONIC_INTERNAL /* The following #define's are used to change the names of the routines defined - * here so that a new library (sonic2) can reuse these names, and then call + * here so that a new library (i.e. speedy) can reuse these names, and then call * the original names. We do this for two reasons: 1) we don't want to change * the original API, and 2) we want to add a shim, using the original names and * still call these routines. @@ -98,6 +101,7 @@ extern "C" { #define sonicChangeFloatSpeed sonicIntChangeFloatSpeed #define sonicChangeShortSpeed sonicIntChangeShortSpeed #define sonicEnableNonlinearSpeedup sonicIntEnableNonlinearSpeedup +#define sonicSetDurationFeedbackStrength sonicIntSetDurationFeedbackStrength #define sonicComputeSpectrogram sonicIntComputeSpectrogram #define sonicGetSpectrogram sonicIntGetSpectrogram @@ -283,3 +287,5 @@ void sonicAddPitchPeriodToSpectrogram(sonicSpectrogram spectrogram, #ifdef __cplusplus } #endif + +#endif /* SONIC_H_ */ diff --git a/spectrogram.c b/spectrogram.c index 8eef8f4..6305130 100644 --- a/spectrogram.c +++ b/spectrogram.c @@ -7,8 +7,9 @@ */ #ifdef KISS_FFT -#include /* kiss_fft.h fails to load this */ +#include /* kiss_fft.h failes to load this */ #include +#include #else #include #endif @@ -369,9 +370,3 @@ int sonicWritePGM(sonicBitmap bitmap, char* fileName) { fclose(file); return 1; } - -#ifdef MAIN -main(){ - -} -#endif diff --git a/wave.c b/wave.c index ace469a..65d1a22 100644 --- a/wave.c +++ b/wave.c @@ -177,7 +177,7 @@ static int readHeader(waveFile file) { data = readShort(file); /* 20 - what is the audio format? 1 for PCM = Pulse Code Modulation */ if (data != 1) { - fprintf(stderr, "Only PCM wave files are supported\n"); + fprintf(stderr, "Only PCM wave files are supported (not %d)\n", data); return 0; } file->numChannels = -- cgit v1.2.3