Table of Contents

Getting Started

Welcome to SignalSharp! This guide will help you install the library and get started with basic signal processing tasks.

Installation

To install SignalSharp, you can use the .NET CLI:

dotnet add package SignalSharp

Alternatively, you can add SignalSharp to your project via the NuGet Package Manager UI in Visual Studio, JetBrains Rider, or your preferred IDE.

Library Overview

SignalSharp provides a range of tools organized into several categories:

Basic Usage Example: Applying the Savitzky-Golay Filter

Let's demonstrate a common use case: smoothing a noisy signal using the Savitzky-Golay filter. This filter fits polynomial segments to the data, which can reduce noise while preserving the shape of features like peaks better than a simple moving average.

  1. Prepare your data: Start with an array representing your signal.

    // Sample noisy signal (at least 2 * windowLength + 1 samples are required)
    double[] noisySignal = {1.0, 2.5, 2.0, 3.5, 4.0, 5.0, 4.5, 6.0, 5.5, 6.5, 7.0, 6.8};
    
  2. Apply the filter: Use SavitzkyGolayFilter.Apply method. You need to specify the windowLength (odd number, how many points to use for each polynomial fit) and the polynomialOrder (degree of the polynomial, must be less than windowLength).

    using SignalSharp.Smoothing.SavitzkyGolay; // Import the necessary namespace
    using System; // For Console.WriteLine
    
    // Sample noisy signal (at least 2 * windowLength + 1 samples are required)
    double[] noisySignal = {1.0, 2.5, 2.0, 3.5, 4.0, 5.0, 4.5, 6.0, 5.5, 6.5, 7.0, 6.8};
    
    // Define filter parameters
    int windowLength = 5; // Use 5 points for each polynomial fit
    int polynomialOrder = 2; // Fit a 2nd degree (quadratic) polynomial
    
    // Apply the filter
    double[] smoothedSignal = SavitzkyGolayFilter.Apply(
        inputSignal: noisySignal,
        windowLength: windowLength,
        polynomialOrder: polynomialOrder
    );
    
    // Display the results
    Console.WriteLine("Original Signal: " + string.Join(", ", noisySignal));
    Console.WriteLine("Smoothed Signal: " + string.Join(", ", smoothedSignal));
    

    (Note: The exact output depends on the filter parameters and implementation details, but it will be a smoothed version of the input.)

Next Steps

This example shows just one capability of SignalSharp. To learn more about specific algorithms and see detailed usage examples:

  • Explore the documentation pages for Detection, Smoothing, and Resampling.
  • Check the API Reference section linked within each algorithm's documentation page.

Dive into the specific documentation relevant to your task to understand the available options and best practices.