mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
Isolate AudioEncode submodule
Isolate AudioEncode from rest of the project, minor cleanups
This commit is contained in:
parent
506521695a
commit
f1737d2a19
@ -1,6 +1,13 @@
|
||||
set(HEADERS)
|
||||
set(CPPS
|
||||
encoder.cpp)
|
||||
encoder.cpp
|
||||
)
|
||||
|
||||
add_library(AudioEncode STATIC ${HEADERS} ${CPPS})
|
||||
target_link_libraries(AudioEncode libacm)
|
||||
add_library(AudioEncode STATIC ${CPPS})
|
||||
target_link_libraries(AudioEncode PRIVATE
|
||||
libacm
|
||||
)
|
||||
target_include_directories(AudioEncode PUBLIC
|
||||
$<BUILD_INTERFACE:
|
||||
${PROJECT_SOURCE_DIR}/AudioEncode
|
||||
>
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Descent 3
|
||||
* Descent 3
|
||||
* Copyright (C) 2024 Parallax Software
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -31,8 +31,8 @@
|
||||
* $NoKeywords: $
|
||||
*/
|
||||
|
||||
#ifndef __AUDIO_ENCODE_H_
|
||||
#define __AUDIO_ENCODE_H_
|
||||
#ifndef AUDIO_ENCODE_H_
|
||||
#define AUDIO_ENCODE_H_
|
||||
|
||||
// input_levels (default 7 or for 2k total)
|
||||
// input_samples (default 16 or for 2k total)
|
||||
@ -40,8 +40,9 @@
|
||||
// input_channels (default 1)
|
||||
// input_factor (compression factor) (default 4 for 22K, 8 for 44K)
|
||||
// input_volscale (Volume scaling) (slightly <= 1.0, default ,97)
|
||||
bool aenc_Compress(char *input_filename, char *output_filename, int *input_levels = nullptr, int *input_samples = nullptr,
|
||||
int *input_rate = nullptr, int *input_channels = nullptr, float *input_factor = nullptr,
|
||||
float *input_volscale = nullptr);
|
||||
bool aenc_Compress(char *input_filename, char *output_filename, const int *input_levels = nullptr,
|
||||
const int *input_samples = nullptr, const int *input_rate = nullptr,
|
||||
const int *input_channels = nullptr, const float *input_factor = nullptr,
|
||||
const float *input_volscale = nullptr);
|
||||
|
||||
#endif
|
@ -1,25 +1,24 @@
|
||||
/*
|
||||
* Descent 3
|
||||
* Copyright (C) 2024 Parallax Software
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
* Descent 3
|
||||
* Copyright (C) 2024 Parallax Software
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <cstdint>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstdio>
|
||||
|
||||
#include "audio_encode.h"
|
||||
#include "mono.h"
|
||||
#include "Aencode.h"
|
||||
@ -37,8 +36,9 @@ int32_t aenc_ReadSamp(void *data) {
|
||||
return (b << 8) | a;
|
||||
}
|
||||
|
||||
bool aenc_Compress(char *input_filename, char *output_filename, int *input_levels, int *input_samples, int *input_rate,
|
||||
int *input_channels, float *input_factor, float *input_volscale) {
|
||||
bool aenc_Compress(char *input_filename, char *output_filename, const int *input_levels, const int *input_samples,
|
||||
const int *input_rate, const int *input_channels, const float *input_factor,
|
||||
const float *input_volscale) {
|
||||
FILE *in, *out;
|
||||
int32_t result;
|
||||
|
||||
@ -90,7 +90,7 @@ bool aenc_Compress(char *input_filename, char *output_filename, int *input_level
|
||||
factor = *input_factor; // Factor of compression (default 4 for 22K, 8 for 44K)
|
||||
factor_set = 1;
|
||||
|
||||
if (factor < 1.0f && factor)
|
||||
if (factor != 0.0f && factor < 1.0f)
|
||||
factor = 1.0f / factor;
|
||||
|
||||
if (factor <= 0.0f) {
|
||||
@ -114,9 +114,7 @@ bool aenc_Compress(char *input_filename, char *output_filename, int *input_level
|
||||
} else if (!levels_set) {
|
||||
unsigned subbands = (2048 / samples_per_subband) >> 1;
|
||||
|
||||
for (levels = 0; subbands; subbands >>= 1, ++levels)
|
||||
{
|
||||
|
||||
for (levels = 0; subbands; subbands >>= 1, ++levels) {
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user