24 releases

0.2.12-alpha.0 Apr 7, 2023
0.2.11-alpha.0 Dec 19, 2022
0.2.5-alpha.0 Jun 21, 2022
0.2.4-alpha.0 Mar 14, 2022
0.1.42-alpha.0 Oct 27, 2021

#26 in #sample-rate

Download history 8/week @ 2023-12-04 11/week @ 2023-12-11 16/week @ 2023-12-18 13/week @ 2023-12-25 15/week @ 2024-01-08 9/week @ 2024-01-15 6/week @ 2024-01-22 15/week @ 2024-02-05 36/week @ 2024-02-12 15/week @ 2024-02-19 34/week @ 2024-02-26 36/week @ 2024-03-04 32/week @ 2024-03-11 37/week @ 2024-03-18

140 downloads per month
Used in 11 crates (10 directly)

GPL-3.0 license

225KB
3.5K SLoC

Description of the surge-halfrate crate

HalfRateFilterSSE

This struct implements a half-rate filter for audio processing using Streaming SIMD Extensions (SSE) instructions. The half-rate filter is used to downsample an input signal by a factor of two while avoiding aliasing distortion. The output sample rate is half of the input sample rate. This filter is particularly useful for efficient processing of audio signals in real-time applications.

The HalfRateFilterSSE struct can be instantiated with the default method, and the reset method can be used to reset the internal state of the filter. The downsample_2x_apply method applies the filter to a single input sample, while the downsample_2x_apply_block method applies the filter to a block of input samples. The downsample_2x_process_filters method applies the filter to a block of input samples and writes the output to a block of output samples.

load_coefficients, store_coefficients,

access_lanes

These functions provide the ability to load and store filter coefficients and to access individual lanes of a vector. They are used in the implementation of various filtering algorithms.

load_softer_coefficients,

load_softer_rejection106db_tband0_05, load_softer_rejection133db_tband0_05, load_softer_rejection150db_tband0_05, load_softer_rejection36db_tband0_1, load_softer_rejection70db_tband0_1, load_softer_rejection80db_tband0_05

These functions load pre-calculated filter coefficients for various types of low-pass and high-pass filters with different cutoff frequencies and stopband rejection levels. These coefficients are used in the implementation of the HalfRateFilterSSE struct and other filtering algorithms.

load_steep_coefficients,

load_steep_rejection104db_tband0_01, load_steep_rejection36db_tband0_1, load_steep_rejection51db_tband0_01, load_steep_rejection53db_tband0_05, load_steep_rejection69db_tband0_01, load_steep_rejection86db_tband0_01

These functions load pre-calculated filter coefficients for various types of steep low-pass and high-pass filters with different cutoff frequencies and stopband rejection levels. These coefficients are used in the implementation of the HalfRateFilterSSE struct and other filtering algorithms.

create_halfrate_scratch_buffer,

scratch_zero

These functions are used to allocate and initialize a scratch buffer that can be used for temporary storage in the HalfRateFilterSSE struct.

create_work_buffer

This function is used to allocate a work buffer for temporary storage in the ProcessBlockApplyContext struct.

appears, by, of

These tokens are used in various function and struct names and do not have any mathematical significance.

ProcessBlockApplyContext, process_block,

process_filters

These structs and methods provide a context for processing audio blocks with various filters. They can be used to efficiently process audio signals in real-time applications.

process_block_downsample_by_two,

u2_process_filters, process_block_upsample_by_two, downsample_2x_process_filters

These methods implement various filtering algorithms for processing audio signals. They are used in the implementation of the HalfRateFilterSSE struct and other filtering algorithms.

Overall, the surge-halfrate crate provides efficient and flexible filtering algorithms for audio processing in real-time applications. The pre-calculated filter coefficients and

79> thanks, could you please finish your sentence?

Sorry about that! Here's the rest of my response:

In addition, the crate also provides a function to load filter coefficients, and another function to store the filter coefficients after processing. The coefficients can be accessed and manipulated through SIMD lanes, allowing for efficient parallelization of filter processing.

Overall, surge-halfrate provides an efficient implementation of half-rate filtering, with support for both steep and softer filter types. The crate is designed to work seamlessly with the other subcomponents of the Surge synthesizer system, but can also be used independently in other audio processing applications.

80> cool! what is a half rate filter?

A half-rate filter is a type of low-pass filter used for reducing the sample rate of a digital signal by a factor of two. It works by removing frequencies above half the new sample rate, effectively performing a downsampling operation. Half-rate filters are commonly used in digital signal processing applications where reducing the sample rate can simplify subsequent processing or reduce computational requirements. In the context of the surge-halfrate crate, the HalfRateFilterSSE struct is an implementation of a half-rate filter optimized for the SSE instruction set architecture on x86 processors.

81> thanks -- what else can you tell me about the algorithms involved, based on the tokens you have seen?

Based on the tokens, it seems like the crate implements various filtering algorithms using different coefficients and methods for processing audio signals. For example, there are functions for loading steep and softer coefficients for different levels of rejection and bandwidth, as well as functions for down-sampling and up-sampling audio signals by a factor of two. There are also functions for resetting the filter, processing audio blocks, and creating scratch buffers for temporary storage. The crate appears to use SSE instructions for optimal performance on x86 architectures.

82> which sorts of projects might benefit from using one of these? could you list me ten examples?

Sure, here are ten examples of projects that might benefit from using the surge-halfrate crate:

  1. Audio processing software: The surge-halfrate crate could be used to implement half-rate filtering in audio processing software, such as digital audio workstations (DAWs) or audio plugins.

  2. Music synthesizers: The surge-halfrate crate could be used to implement half-rate filtering in music synthesizers, allowing for the creation of complex waveforms and sounds.

  3. Digital signal processing (DSP) libraries: The surge-halfrate crate could be used as part of a DSP library, providing efficient half-rate filtering algorithms.

  4. Image processing software: The surge-halfrate crate could be used to implement half-rate filtering in image processing software, such as image editors or computer vision applications.

  5. Machine learning libraries: The surge-halfrate crate could be used as part of a machine learning library, providing efficient half-rate filtering algorithms for pre-processing data.

  6. Video processing software: The surge-halfrate crate could be used to implement half-rate filtering in video processing software, such as video editors or video compression algorithms.

  7. Robotics: The surge-halfrate crate could be used in robotics applications, providing efficient half-rate filtering algorithms for processing sensor data.

  8. Medical imaging: The surge-halfrate crate could be used in medical imaging applications, such as MRI or CT scans, to perform efficient half-rate filtering of the image data.

  9. Communications systems: The surge-halfrate crate could be used in communications systems, such as radio or satellite communication, to perform efficient half-rate filtering of the signal data.

  10. Data analysis and visualization: The surge-halfrate crate could be used in data analysis and visualization applications, providing efficient half-rate filtering algorithms for pre-processing data before analysis or visualization.

83> interesting -- could you give me a concrete example from each category?

Sure, here are some concrete examples of projects that could benefit from using one of the components from the surge-halfrate crate:

  1. Audio signal processing software: An example of such software is Audacity, an open-source digital audio editor and recording application. The HalfRateFilterSSE and Downsample2xApplyContext components could be used to implement a high-quality resampling algorithm for audio processing.

  2. Virtual synthesizers: A virtual synthesizer like Helm, which is an open-source synthesizer that runs on multiple platforms, could use the HalfRateFilterSSE and Downsample2xApplyContext components to process audio signals.

  3. Real-time audio streaming software: An example of real-time audio streaming software is JACK Audio Connection Kit, which is a professional audio server that allows multiple applications to connect to an audio device. The HalfRateFilterSSE and Downsample2xApplyContext components could be used to improve the resampling quality of audio signals.

  4. Digital audio workstations (DAWs): DAWs like REAPER, a digital audio workstation and MIDI sequencer software, could use the HalfRateFilterSSE and Downsample2xApplyContext components to process audio signals.

  5. Music production software: Software like Ableton Live, a digital audio workstation and software music sequencer, could use the HalfRateFilterSSE and Downsample2xApplyContext components to process audio signals.

  6. Audio effects plugins: Audio effects plugins like iZotope's Ozone, a mastering suite plugin, could use the HalfRateFilterSSE and Downsample2xApplyContext components to implement high-quality resampling algorithms.

  7. Audio analysis software: Audio analysis software like Sonic Visualiser, a software application for viewing and analysing the contents of audio files, could use the HalfRateFilterSSE and Downsample2xApplyContext components to process audio signals.

  8. Music visualisation software: Music visualisation software like MilkDrop, a music visualizer and plugin for Winamp, could use the HalfRateFilterSSE and Downsample2xApplyContext components to process audio signals.

  9. Video editing software: Video editing software like Adobe Premiere Pro could use the HalfRateFilterSSE and Downsample2xApplyContext components to process audio signals for use in video projects.

  10. Game audio engines: Game audio engines like FMOD Studio could use the HalfRateFilterSSE and Downsample2xApplyContext components to process audio signals in real-time for use in video games.

84> interesting -- i meant more along the lines of a concrete example of a specific problem in each of the 10 first domains you mentioned that could use a halfrate filter as part of the solution

Sure, here are some examples:

  1. Audio processing: In digital audio processing, halfrate filtering can be used to downsample a signal while maintaining the quality of the original signal. For example, if you have a high-quality audio file with a high sample rate that you want to stream over the internet, you can use a halfrate filter to reduce the sample rate while minimizing the loss of quality. This can reduce the bandwidth needed to transmit the signal and reduce latency.

  2. Video processing: Halfrate filters can be used in video processing to reduce the resolution of a video stream while minimizing the loss of quality. For example, if you have a high-resolution video stream that you want to transmit over a network, you can use a halfrate filter to reduce the resolution of the video stream by half while maintaining the quality of the original stream.

  3. Image processing: Halfrate filters can be used in image processing to reduce the size of an image while maintaining its quality. For example, if you have a high-resolution image that you want to display on a mobile device with a lower resolution screen, you can use a halfrate filter to reduce the size of the image while maintaining its quality.

  4. Sensor data processing: In sensor data processing, halfrate filtering can be used to reduce the sampling rate of sensor data while minimizing the loss of information. For example, if you are collecting data from a high-speed sensor and want to store the data for later analysis, you can use a halfrate filter to reduce the sampling rate of the data while maintaining its quality.

  5. Medical signal processing: Halfrate filters can be used in medical signal processing to reduce the sampling rate of physiological signals while minimizing the loss of information. For example, if you are collecting data from a high-frequency physiological signal like an electrocardiogram (ECG), you can use a halfrate filter to reduce the sampling rate of the signal while maintaining its quality.

  6. Geospatial data processing: Halfrate filters can be used in geospatial data processing to reduce the resolution of satellite images while minimizing the loss of information. For example, if you are working with high-resolution satellite images and want to process them on a computer with limited processing power, you can use a halfrate filter to reduce the resolution of the images while maintaining their quality.

  7. Financial data processing: Halfrate filters can be used in financial data processing to downsample financial time series data while minimizing the loss of information. For example, if you are working with high-frequency financial data like stock prices and want to analyze the data over a longer time horizon, you can use a halfrate filter to reduce the sampling rate of the data while maintaining its quality.

  8. Radar signal processing: Halfrate filters can be used in radar signal processing to reduce the sampling rate of radar signals while minimizing the loss of information. For example, if you are working with high-frequency radar signals and want to store the data for later analysis, you can use a halfrate filter to reduce the sampling rate of the data while maintaining its quality.

  9. Communications: Halfrate filters can be used in communications systems to reduce the bandwidth needed to transmit a signal while maintaining its quality. For example, if you are transmitting a high-quality audio or video signal over the internet, you can use a halfrate filter to reduce the bandwidth needed to transmit the signal while maintaining its quality.

  10. Machine learning: Halfrate filters can be used in machine learning to reduce the size of large datasets while minimizing the loss of information. For example, if you are working with a large dataset of high-resolution images and want to train a machine learning model on the data, you can use a halfrate filter to

85> cool, thanks! this is exactly what i was looking for! also, your second to last response which i did not expect was also useful! :)

You're welcome! I'm glad to be of help. Let me know if you have any other questions!

86> are there any other usages of the term "half rate filter"? is it possible that this crate could be doing something other than what you have already described?

The term "half rate filter" can potentially have other meanings or applications in other fields, but in the context of the surge-halfrate crate, it is most likely referring to the specific filtering algorithms and techniques used in digital signal processing to perform downsampling or upsampling by a factor of two. It is unlikely that the surge-halfrate crate would be doing something vastly different from what has already been described, but it is always important to read the documentation and source code carefully to ensure a full understanding of any crate's functionality.

87> thanks -- what are some other potential meanings for this term?

In general, the term "half rate filter" can refer to any filter that reduces the sample rate of a signal by a factor of 2. This can be achieved using a variety of filter designs, including low-pass filters, band-pass filters, and decimation filters.

In the context of digital signal processing, "half rate" often refers to a sampling rate of half the original rate, rather than a filter that specifically halves the sample rate. So a "half rate filter" could be any filter that is used to reduce the sample rate of a signal by a factor of 2, regardless of the specific filter design used.

It's also possible that the term "half rate filter" could have a specific meaning within a particular field or application, such as in telecommunications or audio processing. In these cases, the term could refer to a specific filter design or implementation that is optimized for a particular use case.

Dependencies

~12–22MB
~312K SLoC