summaryrefslogtreecommitdiff
path: root/apps/plugins/wav2wv.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/wav2wv.c')
-rw-r--r--apps/plugins/wav2wv.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/apps/plugins/wav2wv.c b/apps/plugins/wav2wv.c
index 7e85572d78..5b71e7e759 100644
--- a/apps/plugins/wav2wv.c
+++ b/apps/plugins/wav2wv.c
@@ -42,42 +42,42 @@ static int audiobuflen;
42 42
43static struct wav_header { 43static struct wav_header {
44 char ckID [4]; /* RIFF chuck header */ 44 char ckID [4]; /* RIFF chuck header */
45 long ckSize; 45 int32_t ckSize;
46 char formType [4]; 46 char formType [4];
47 47
48 char fmt_ckID [4]; /* format chunk header */ 48 char fmt_ckID [4]; /* format chunk header */
49 long fmt_ckSize; 49 int32_t fmt_ckSize;
50 ushort FormatTag, NumChannels; 50 ushort FormatTag, NumChannels;
51 ulong SampleRate, BytesPerSecond; 51 uint32_t SampleRate, BytesPerSecond;
52 ushort BlockAlign, BitsPerSample; 52 ushort BlockAlign, BitsPerSample;
53 53
54 char data_ckID [4]; /* data chunk header */ 54 char data_ckID [4]; /* data chunk header */
55 long data_ckSize; 55 int32_t data_ckSize;
56} raw_header, native_header; 56} raw_header, native_header;
57 57
58#define WAV_HEADER_FORMAT "4L44LSSLLSS4L" 58#define WAV_HEADER_FORMAT "4L44LSSLLSS4L"
59 59
60static void wvupdate (long start_tick, 60static void wvupdate (int32_t start_tick,
61 long sample_rate, 61 int32_t sample_rate,
62 ulong total_samples, 62 uint32_t total_samples,
63 ulong samples_converted, 63 uint32_t samples_converted,
64 ulong bytes_read, 64 uint32_t bytes_read,
65 ulong bytes_written) 65 uint32_t bytes_written)
66{ 66{
67 long elapsed_ticks = *rb->current_tick - start_tick; 67 int32_t elapsed_ticks = *rb->current_tick - start_tick;
68 int compression = 0, progress = 0, realtime = 0; 68 int compression = 0, progress = 0, realtime = 0;
69 char buf[32]; 69 char buf[32];
70 70
71 if (total_samples) 71 if (total_samples)
72 progress = (int)(((long long) samples_converted * 100 + 72 progress = (int)(((int64_t) samples_converted * 100 +
73 (total_samples/2)) / total_samples); 73 (total_samples/2)) / total_samples);
74 74
75 if (elapsed_ticks) 75 if (elapsed_ticks)
76 realtime = (int)(((long long) samples_converted * 100 * HZ / 76 realtime = (int)(((int64_t) samples_converted * 100 * HZ /
77 sample_rate + (elapsed_ticks/2)) / elapsed_ticks); 77 sample_rate + (elapsed_ticks/2)) / elapsed_ticks);
78 78
79 if (bytes_read) 79 if (bytes_read)
80 compression = (int)(((long long)(bytes_read - bytes_written) * 100 + 80 compression = (int)(((int64_t)(bytes_read - bytes_written) * 100 +
81 (bytes_read/2)) / bytes_read); 81 (bytes_read/2)) / bytes_read);
82 82
83 rb->snprintf(buf, 32, "elapsed time: %d secs", (elapsed_ticks + (HZ/2)) / HZ); 83 rb->snprintf(buf, 32, "elapsed time: %d secs", (elapsed_ticks + (HZ/2)) / HZ);
@@ -99,19 +99,19 @@ static void wvupdate (long start_tick,
99 99
100#define TEMP_SAMPLES 4096 100#define TEMP_SAMPLES 4096
101 101
102static long temp_buffer [TEMP_SAMPLES] IDATA_ATTR; 102static int32_t temp_buffer [TEMP_SAMPLES] IDATA_ATTR;
103 103
104static int wav2wv (char *filename) 104static int wav2wv (char *filename)
105{ 105{
106 int in_fd, out_fd, num_chans, error = false, last_buttons; 106 int in_fd, out_fd, num_chans, error = false, last_buttons;
107 unsigned long total_bytes_read = 0, total_bytes_written = 0; 107 unsigned int32_t total_bytes_read = 0, total_bytes_written = 0;
108 unsigned long total_samples, samples_remaining; 108 unsigned int32_t total_samples, samples_remaining;
109 long *input_buffer = (long *) audiobuf; 109 int32_t *input_buffer = (int32_t *) audiobuf;
110 unsigned char *output_buffer = (unsigned char *)(audiobuf + 0x100000); 110 unsigned char *output_buffer = (unsigned char *)(audiobuf + 0x100000);
111 char *extension, save_a; 111 char *extension, save_a;
112 WavpackConfig config; 112 WavpackConfig config;
113 WavpackContext *wpc; 113 WavpackContext *wpc;
114 long start_tick; 114 int32_t start_tick;
115 115
116 rb->lcd_clear_display(); 116 rb->lcd_clear_display();
117 rb->lcd_puts_scroll(0, 0, (unsigned char *)filename); 117 rb->lcd_puts_scroll(0, 0, (unsigned char *)filename);
@@ -188,9 +188,9 @@ static int wav2wv (char *filename)
188 wvupdate (start_tick, native_header.SampleRate, total_samples, 0, 0, 0); 188 wvupdate (start_tick, native_header.SampleRate, total_samples, 0, 0, 0);
189 189
190 for (samples_remaining = total_samples; samples_remaining;) { 190 for (samples_remaining = total_samples; samples_remaining;) {
191 unsigned long samples_count, samples_to_pack, bytes_count; 191 unsigned int32_t samples_count, samples_to_pack, bytes_count;
192 int cnt, buttons; 192 int cnt, buttons;
193 long value, *lp; 193 int32_t value, *lp;
194 signed char *cp; 194 signed char *cp;
195 195
196 samples_count = SAMPLES_PER_BLOCK; 196 samples_count = SAMPLES_PER_BLOCK;
@@ -200,7 +200,7 @@ static int wav2wv (char *filename)
200 200
201 bytes_count = samples_count * num_chans * 2; 201 bytes_count = samples_count * num_chans * 2;
202 202
203 if (rb->read (in_fd, input_buffer, bytes_count) != (long) bytes_count) { 203 if (rb->read (in_fd, input_buffer, bytes_count) != (int32_t) bytes_count) {
204 rb->splash(HZ*2, true, "could not read file!"); 204 rb->splash(HZ*2, true, "could not read file!");
205 error = true; 205 error = true;
206 break; 206 break;
@@ -212,7 +212,7 @@ static int wav2wv (char *filename)
212 cp = (signed char *) input_buffer; 212 cp = (signed char *) input_buffer;
213 213
214 while (samples_to_pack) { 214 while (samples_to_pack) {
215 unsigned long samples_this_pass = TEMP_SAMPLES / num_chans; 215 unsigned int32_t samples_this_pass = TEMP_SAMPLES / num_chans;
216 216
217 if (samples_this_pass > samples_to_pack) 217 if (samples_this_pass > samples_to_pack)
218 samples_this_pass = samples_to_pack; 218 samples_this_pass = samples_to_pack;
@@ -250,7 +250,7 @@ static int wav2wv (char *filename)
250 250
251 bytes_count = WavpackFinishBlock (wpc); 251 bytes_count = WavpackFinishBlock (wpc);
252 252
253 if (rb->write (out_fd, output_buffer, bytes_count) != (long) bytes_count) { 253 if (rb->write (out_fd, output_buffer, bytes_count) != (int32_t) bytes_count) {
254 rb->splash(HZ*2, true, "could not write file!"); 254 rb->splash(HZ*2, true, "could not write file!");
255 error = true; 255 error = true;
256 break; 256 break;