summaryrefslogtreecommitdiff
path: root/src/c_asndfile_command.c
blob: 2955d91ea81ecfd174e46d0ed37808f05d5221de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122


//  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_cart_info = SFC_GET_CART_INFO;
const int sfc_set_cart_info = SFC_SET_CART_INFO;
const int sfc_get_loop_info = SFC_GET_LOOP_INFO;
const int sfc_get_instrument = SFC_GET_INSTRUMENT;
const int sfc_set_instrument = SFC_SET_INSTRUMENT;
const int sfc_get_cue_count = SFC_GET_CUE_COUNT;
const int sfc_get_cue = SFC_GET_CUE;
const int sfc_set_cue = SFC_SET_CUE;
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_loop_none = SF_LOOP_NONE;
const int sf_loop_forward = SF_LOOP_FORWARD;
const int sf_loop_backward = SF_LOOP_BACKWARD;
const int sf_loop_alternating = SF_LOOP_ALTERNATING;

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;
}