are you me?    id passwd

status  

 Busy..

picture

 

 How to manage your time effectively?

calender

upsampling example 8khz to 16khz by using libsoxr - 컴퓨터

/* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net
* Licence for this file: LGPL v2.1 See LICENCE for details. */

/* Example 5: Variable-rate resampling (N.B. experimental). A test signal
* (held in a buffer) is resampled over a wide range of octaves. Resampled
* data is sent to stdout as raw, float32 samples. Choices of 2 test-signals
* and of 2 ways of varying the sample-rate are combined in a command-line
* option:
*
* Usage: ./5-variable-rate [0|1|2|3]
*/

#include <soxr.h>


/* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net
* Licence for this file: LGPL v2.1 See LICENCE for details. */

/* Common includes etc. for the examples. */

#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <math.h>
#include <stddef.h>
#include <stdio.h>
#include &lt;stdlib.h>
#include <string.h>

#define USE_STD_STDIO

#undef int16_t
#define int16_t short

#undef int32_t
#if LONG_MAX > 2147483647L
#define int32_t int
#elif LONG_MAX < 2147483647L
#error this programme requires that 'long int' has at least 32-bits
#else
#define int32_t long
#endif

#undef min
#undef max
#define min(x,y) ((x)<(y)?(x):(y))
#define max(x,y) ((x)>(y)?(x):(y))

#define AL(a) (sizeof(a)/sizeof((a)[0])) /* Array Length */


//#include "examples-common.h"

int main(int argc, char *arg[])
{
// int opt = argc <= 1? 2 : (atoi(arg[1]) & 3), saw = opt & 1,
// float ibuf[10 << OCTAVES], obuf[AL(ibuf)];
short ibuf[83480], obuf[640];
int i;//, wl = 2 << OCTAVES;
size_t ilen = AL(ibuf), need_input = 1;
size_t odone, total_odone, total_olen = 166960;

size_t olen1 = AL(obuf); /* Small block-len if fast-changing ratio */
soxr_error_t error;

/* When creating a var-rate resampler, q_spec must be set as follows: */
// soxr_quality_spec_t q_spec = soxr_quality_spec(SOXR_HQ, SOXR_VR);

/* The ratio of the given input rate and output rates must equate to the
* maximum I/O ratio that will be used: */
soxr_io_spec_t iospec = soxr_io_spec(SOXR_INT16_I, SOXR_INT16_I);
soxr_t soxr = soxr_create(8000, 16000, 1, &error, &iospec, NULL, NULL);

if (!error) {
USE_STD_STDIO;

/* Generate input signal, sine or saw, with wave-length = wl: */
// for (i = 0; i < (int)ilen; ++i)
// ibuf[i] = (float)(saw? (i%wl)/(wl-1.)-.5 : .9 * sin(2 * M_PI * i / wl));
FILE *file;
file = fopen("re8khz.raw", "rb");
fread(ibuf, sizeof(short), 83480, file);
fclose(file);

/* Set the initial resampling ratio (N.B. 3rd parameter = 0): */
// soxr_set_io_ratio(soxr, ioratio(0), 0);

/* Resample in blocks of size olen1: */
for (total_odone = 0; !error && total_odone < total_olen;) {

/* The last block might be shorter: */
size_t block_len = min(olen1, total_olen - total_odone);

/* Determine the position in [0,1] of the end of the current block: */
// double pos = (double)(total_odone + block_len) / (double)total_olen;

/* Calculate an ioratio for this position and instruct the resampler to
* move smoothly to the new value, over the course of outputting the next
* 'block_len' samples (or give 0 for an instant change instead): */
// soxr_set_io_ratio(soxr, ioratio(pos), block_len);

/* Output the block of samples, supplying input samples as needed: */
do {
size_t len = need_input? ilen : 0;
error = soxr_process(soxr, ibuf, len, NULL, obuf, block_len, &odone);
fwrite(obuf, sizeof(short), odone, stdout);

/* Update counters for the current block and for the total length: */
block_len -= odone;
total_odone += odone;

/* If soxr_process did not provide the complete block, we must call it
* again, supplying more input samples: */
need_input = block_len != 0;

} while (need_input && !error);

/* Now that the block for the current ioratio is complete, go back
* round the main `for' loop in order to process the next block. */
}
soxr_delete(soxr);
}
/* Diagnostics: */
fprintf(stderr, "%-26s %s; I/O: %s
", arg[0], soxr_strerror(error),
ferror(stdin) || ferror(stdout)? strerror(errno) : "no error");
return !!error;
}

파일명 :  upsampling_20170816.7z

written time : 2017-08-16 23:04:17.0

바쁜 와중 이지만 - 일상

나의 일상도 소중하므로

upgrade complete

한판만 ㅠ

written time : 2017-08-15 20:43:36.0

책을 한 번 읽고나면 그 책에 대해서 - 생각

모르는 게 없는 것 같은 착각을 하곤 하지만
책을 다시 펴보는 것은 물론이거니와
심지어 내가 일전에 이해해서 정리했던 글을 읽다보면
내가 단단히 착각하고 있다는 사실을 깨닫게 된다.

물론 모든 내용을 완벽히 이해한 적은 없기 때문에
완전히 생소한 것은 기억을 더듬어 자료를 찾아봐도 대부분 정리된 것이 애초에 없다.

여러번 읽기 전에는 처음에 놓친 내용이 무엇인지 조차 알지 못하니
이래서 책을 여러번 읽어야 하는 건가 싶다.

그래서 갑자기 떠오른 빅쇼트의 시작 문구

"It ain't what you don't know that gets you into trouble. It's what you know for sure that just ain't so.", a fake Mark Twain quote used in The Big Short

written time : 2017-08-13 21:03:49.0
...  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |  ...