summaryrefslogtreecommitdiff
path: root/src/c_asndfile_command.c
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2023-07-02 21:36:34 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2023-07-02 21:36:34 +1200
commit049d2a9a337331295b4a2d4ad13061bc73536236 (patch)
treec360b2ce05f91d070c14dad7a3691c1435df7df7 /src/c_asndfile_command.c
Initial commit
Diffstat (limited to 'src/c_asndfile_command.c')
-rw-r--r--src/c_asndfile_command.c112
1 files changed, 112 insertions, 0 deletions
diff --git a/src/c_asndfile_command.c b/src/c_asndfile_command.c
new file mode 100644
index 0000000..1d86b1c
--- /dev/null
+++ b/src/c_asndfile_command.c
@@ -0,0 +1,112 @@
+
+
+// Programmed by Jedidiah Barber
+// Released into the public domain
+
+
+#include <sndfile.h>
+#include "c_asndfile_command.h"
+
+
+
+const int sfc_get_lib_version = SFC_GET_LIB_VERSION;
+const int sfc_get_log_info = SFC_GET_LOG_INFO;
+const int sfc_calc_signal_max = SFC_CALC_SIGNAL_MAX;
+const int sfc_calc_norm_signal_max = SFC_CALC_NORM_SIGNAL_MAX;
+const int sfc_calc_max_all_channels = SFC_CALC_MAX_ALL_CHANNELS;
+const int sfc_calc_norm_max_all_channels = SFC_CALC_NORM_MAX_ALL_CHANNELS;
+const int sfc_get_signal_max = SFC_GET_SIGNAL_MAX;
+const int sfc_get_max_all_channels = SFC_GET_MAX_ALL_CHANNELS;
+const int sfc_set_norm_float = SFC_SET_NORM_FLOAT;
+const int sfc_set_norm_double = SFC_SET_NORM_DOUBLE;
+const int sfc_get_norm_float = SFC_GET_NORM_FLOAT;
+const int sfc_get_norm_double = SFC_GET_NORM_DOUBLE;
+const int sfc_set_scale_float_int_read = SFC_SET_SCALE_FLOAT_INT_READ;
+const int sfc_set_scale_int_float_write = SFC_SET_SCALE_INT_FLOAT_WRITE;
+const int sfc_get_simple_format_count = SFC_GET_SIMPLE_FORMAT_COUNT;
+const int sfc_get_simple_format = SFC_GET_SIMPLE_FORMAT;
+const int sfc_get_format_info = SFC_GET_FORMAT_INFO;
+const int sfc_get_format_major_count = SFC_GET_FORMAT_MAJOR_COUNT;
+const int sfc_get_format_major = SFC_GET_FORMAT_MAJOR;
+const int sfc_get_format_subtype_count = SFC_GET_FORMAT_SUBTYPE_COUNT;
+const int sfc_get_format_subtype = SFC_GET_FORMAT_SUBTYPE;
+const int sfc_set_add_peak_chunk = SFC_SET_ADD_PEAK_CHUNK;
+const int sfc_update_header_now = SFC_UPDATE_HEADER_NOW;
+const int sfc_set_update_header_auto = SFC_SET_UPDATE_HEADER_AUTO;
+const int sfc_set_clipping = SFC_SET_CLIPPING;
+const int sfc_get_clipping = SFC_GET_CLIPPING;
+const int sfc_wavex_get_ambisonic = SFC_WAVEX_GET_AMBISONIC;
+const int sfc_wavex_set_ambisonic = SFC_WAVEX_SET_AMBISONIC;
+const int sfc_set_vbr_encoding_quality = SFC_SET_VBR_ENCODING_QUALITY;
+const int sfc_set_ogg_page_latency_ms = SFC_SET_OGG_PAGE_LATENCY_MS;
+const int sfc_get_ogg_stream_serialno = SFC_GET_OGG_STREAM_SERIALNO;
+const int sfc_set_compression_level = SFC_SET_COMPRESSION_LEVEL;
+const int sfc_raw_data_needs_endswap = SFC_RAW_DATA_NEEDS_ENDSWAP;
+const int sfc_get_broadcast_info = SFC_GET_BROADCAST_INFO;
+const int sfc_set_broadcast_info = SFC_SET_BROADCAST_INFO;
+const int sfc_get_channel_map_info = SFC_GET_CHANNEL_MAP_INFO;
+const int sfc_set_channel_map_info = SFC_SET_CHANNEL_MAP_INFO;
+// ...
+const int sfc_get_cue_count = SFC_GET_CUE_COUNT;
+// ...
+const int sfc_rf64_auto_downgrade = SFC_RF64_AUTO_DOWNGRADE;
+const int sfc_get_original_samplerate = SFC_GET_ORIGINAL_SAMPLERATE;
+const int sfc_set_original_samplerate = SFC_SET_ORIGINAL_SAMPLERATE;
+const int sfc_get_bitrate_mode = SFC_GET_BITRATE_MODE;
+const int sfc_set_bitrate_mode = SFC_SET_BITRATE_MODE;
+
+const int sf_ambisonic_none = SF_AMBISONIC_NONE;
+const int sf_ambisonic_b_format = SF_AMBISONIC_B_FORMAT;
+
+const int sf_bitrate_mode_constant = SF_BITRATE_MODE_CONSTANT;
+const int sf_bitrate_mode_average = SF_BITRATE_MODE_AVERAGE;
+const int sf_bitrate_mode_variable = SF_BITRATE_MODE_VARIABLE;
+
+const unsigned int sf_format_typemask = SF_FORMAT_TYPEMASK;
+const unsigned int sf_format_submask = SF_FORMAT_SUBMASK;
+const unsigned int sf_format_endmask = SF_FORMAT_ENDMASK;
+
+
+
+int asfc_get_current_sf_info(SNDFILE * sndfile, Asf_Info * sfinfo) {
+ SF_INFO actual;
+
+ int result = sf_command(sndfile, SFC_GET_CURRENT_SF_INFO, &actual, sizeof(SF_INFO));
+
+ sfinfo->frames = (long long)actual.frames;
+ sfinfo->samplerate = actual.samplerate;
+ sfinfo->channels = actual.channels;
+ sfinfo->major = actual.format & SF_FORMAT_TYPEMASK;
+ sfinfo->minor = actual.format & SF_FORMAT_SUBMASK;
+ sfinfo->endian = actual.format & SF_FORMAT_ENDMASK;
+ sfinfo->sections = actual.sections;
+ sfinfo->seekable = actual.seekable;
+
+ return result;
+}
+
+
+int asfc_file_truncate(SNDFILE * sndfile, int64_t pos) {
+ sf_count_t actual = (sf_count_t) pos;
+ return sf_command(sndfile, SFC_FILE_TRUNCATE, &actual, sizeof(sf_count_t));
+}
+
+
+int asfc_set_raw_start_offset(SNDFILE * sndfile, int64_t pos) {
+ sf_count_t actual = (sf_count_t) pos;
+ return sf_command(sndfile, SFC_SET_RAW_START_OFFSET, &actual, sizeof(sf_count_t));
+}
+
+
+int asfc_get_embed_file_info(SNDFILE * sndfile, Asf_Embed * sfembed) {
+ SF_EMBED_FILE_INFO actual;
+
+ int result = sf_command(sndfile, SFC_GET_EMBED_FILE_INFO, &actual, sizeof(SF_EMBED_FILE_INFO));
+
+ sfembed->offset = actual.offset;
+ sfembed->length = actual.length;
+
+ return result;
+}
+
+