{"id":21899593,"url":"https://github.com/zephray/samplerateconverter","last_synced_at":"2025-04-15T19:19:19.569Z","repository":{"id":45116061,"uuid":"191970896","full_name":"zephray/SampleRateConverter","owner":"zephray","description":"Audio sample rate converter based on polyphase FIR filter","archived":false,"fork":false,"pushed_at":"2022-01-07T08:28:58.000Z","size":6,"stargazers_count":37,"open_issues_count":3,"forks_count":6,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-15T19:19:00.726Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zephray.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-14T15:57:22.000Z","updated_at":"2025-02-28T23:45:14.000Z","dependencies_parsed_at":"2022-08-26T10:41:27.113Z","dependency_job_id":null,"html_url":"https://github.com/zephray/SampleRateConverter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zephray%2FSampleRateConverter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zephray%2FSampleRateConverter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zephray%2FSampleRateConverter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zephray%2FSampleRateConverter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zephray","download_url":"https://codeload.github.com/zephray/SampleRateConverter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249135832,"owners_count":21218365,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T14:45:19.536Z","updated_at":"2025-04-15T19:19:19.546Z","avatar_url":"https://github.com/zephray.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sample Rate Converter\n\nThis is a C implementation of an audio sample rate convertor based on Polyphase FIR filter. It can be used to up or downconverting the sample rate of a raw audio stream with any fractional ratio. However this may not suitable as an arbitrary resampler as memory space consumption goes up linearly as the numerator of the ratio goes up. The stream should be in de-interleaved 32bit float format. The filter is stateful, capable of processing audio stream with arbitrary block size. The code does not depend on libraries other than standard math library (-lm). The state is decoupled from the algorithm, allowing code re-entrant and multi-instancing.\n\n## Usage\n\nSimple 44.1kHz to 192kHz upsampler:\n\n```C\n#include \"src.h\"\n// 44.1kHz * 640 / 147 = 192kHz\nFIR_Filter* filter = src_generate(640, 147); \n...\nfloat* input_buffer[IN_SIZE]; // Incoming stream\nfloat* output_buffer[IN_SIZE * 5]; // Outcoming stream\nint output_length = src_filt(filter, input_buffer, input_length, output_buffer);\n```\n\nManually pick the number of taps, cutoff frequency, and run mutiple instances:\n\n```C\n#include \"src.h\"\nint interpolation = 2; // x 2\nint decimation = 1;    // / 1\nfloat cutoff_frequency = 0.5; // half the sampling frequency\nint num_taps = 24 * interpolation;\nfloat* coefficients = src_generate_fir_coeffs(num_taps, cutoff_frequency / interpolation);\nFIR_Filter* filter_left = src_generate_fir_filter(coefficients, num_taps, interpolation, decimation);\nFIR_Filter* filter_right = src_generate_fir_filter(coefficients, num_taps, interpolation, decimation);\nfree(coefficients);\n...\nfloat* input_buffer_left[IN_SIZE]; // Incoming stream\nfloat* output_buffer_left[IN_SIZE * interpolation / decimation + 1]; // Outcoming stream\nint output_length = src_filt(filter_left, input_buffer, input_length, output_buffer);\n...\n```\n\nBy default it uses 24 taps per phase and hanning window to construct the filter. This might not be the best configuration. For better filtering quality, higher taps count and kaiser window may be used.\n\n## Performance\n\nOn ADSP-21589 SHARC+ DSP, upsampling 2 channels of audio from 44.1kHz to 48kHz uses ~24 MIPS.\n\n## License\n\nMIT.\n\nJulia-DSP library source code was used as a reference, which is also licensed under MIT.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzephray%2Fsamplerateconverter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzephray%2Fsamplerateconverter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzephray%2Fsamplerateconverter/lists"}