Skip to content

Commit

Permalink
update to ver.0.9.6; update README
Browse files Browse the repository at this point in the history
  • Loading branch information
ar1st0crat committed Oct 7, 2021
1 parent 58c2438 commit 19afb0f
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 23 deletions.
4 changes: 2 additions & 2 deletions NWaves.DemoForms/FeaturesForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e)

var mpeg7Extractor = new Mpeg7SpectralFeaturesExtractor(options);
mpeg7Extractor.IncludeHarmonicFeatures("all");
mpeg7Extractor.SetPitchTrack(pitchTrack);
//mpeg7Extractor.SetPitchTrack(pitchTrack);

options.FeatureList = "sc+sn";
options.Frequencies = freqs;
Expand All @@ -85,7 +85,7 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e)

var tdVectors = tdExtractor.ParallelComputeFrom(_signal);
var spectralVectors = spectralExtractor.ParallelComputeFrom(_signal);
var mpeg7Vectors = mpeg7Extractor.ComputeFrom(_signal);
var mpeg7Vectors = mpeg7Extractor.ParallelComputeFrom(_signal);

_vectors = FeaturePostProcessing.Join(tdVectors, spectralVectors, mpeg7Vectors);

Expand Down
11 changes: 5 additions & 6 deletions NWaves.DemoForms/ModulationForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public enum ModulationMode
Phase
}

Modulator _modulator = new Modulator();
ModulationMode _modulationMode = ModulationMode.Amplitude;
DiscreteSignal _modulated;

Expand Down Expand Up @@ -50,15 +49,15 @@ private void modulateButton_Click(object sender, EventArgs e)
switch (_modulationMode)
{
case ModulationMode.Frequency:
_modulated = _modulator.Frequency(baseband, carrierAmplitude, carrierFrequency);
_modulated = Modulator.Frequency(baseband, carrierAmplitude, carrierFrequency);
break;

case ModulationMode.Phase:
_modulated = _modulator.Phase(baseband, carrierAmplitude, carrierFrequency);
_modulated = Modulator.Phase(baseband, carrierAmplitude, carrierFrequency);
break;

default:
_modulated = _modulator.Amplitude(carrier, modulationFrequency, modulationIndex);
_modulated = Modulator.Amplitude(carrier, modulationFrequency, modulationIndex);
break;
}

Expand All @@ -74,11 +73,11 @@ private void demodulateButton_Click(object sender, EventArgs e)
{
case ModulationMode.Frequency:
case ModulationMode.Phase:
demodulated = _modulator.DemodulateFrequency(_modulated);
demodulated = Modulator.DemodulateFrequency(_modulated);
break;

default:
demodulated = _modulator.DemodulateAmplitude(_modulated);
demodulated = Modulator.DemodulateAmplitude(_modulated);
break;
}

Expand Down
4 changes: 2 additions & 2 deletions NWaves.DemoForms/NWaves.DemoForms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="NWaves, Version=0.9.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NWaves.0.9.5\lib\netstandard2.0\NWaves.dll</HintPath>
<Reference Include="NWaves, Version=0.9.6.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NWaves.0.9.6\lib\netstandard2.0\NWaves.dll</HintPath>
</Reference>
<Reference Include="SciColorMaps, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ar1st0crat.SciColorMaps.1.0.2\lib\portable40-net40+sl5+win8+wpa81\SciColorMaps.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion NWaves.DemoForms/SignalsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using NWaves.Audio.Interfaces;
using NWaves.Audio.Mci;
using NWaves.Signals;
using NWaves.Signals.Builders.Base;
using NWaves.Signals.Builders;
using NWaves.Transforms;
using NWaves.Transforms.Wavelets;

namespace NWaves.DemoForms
{
Expand Down
7 changes: 3 additions & 4 deletions NWaves.DemoForms/StftForm.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
using NWaves.Audio;
using NWaves.Filters;
using NWaves.Operations;
using NWaves.Signals;
using NWaves.Transforms;
Expand Down Expand Up @@ -61,14 +59,15 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e)
var processed = _stft.Inverse(_stft.Direct(_signal));
_processedSignal = new DiscreteSignal(_signal.SamplingRate, processed);


// 1) check also this:
//var mp = _stft.MagnitudePhaseSpectrogram(_signal);
//var processed = _stft.ReconstructMagnitudePhase(mp, false);
//_processedSignal = new DiscreteSignal(_signal.SamplingRate, processed);

// 2) or check this:
//var processed = new GriffinLimReconstructor(_spectrogram, _stft).Reconstruct();
//var gl = new GriffinLimReconstructor(_spectrogram, 512, 128, _windowType) { Gain = 20 };
//var processed = gl.Reconstruct(16);
//_processedSignal = new DiscreteSignal(_signal.SamplingRate, processed);

signalPanel.Gain = 120;
Expand Down
2 changes: 1 addition & 1 deletion NWaves.DemoForms/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ar1st0crat.SciColorMaps" version="1.0.2" targetFramework="net452" />
<package id="NWaves" version="0.9.5" targetFramework="net462" />
<package id="NWaves" version="0.9.6" targetFramework="net462" />
</packages>
2 changes: 1 addition & 1 deletion NWaves.DemoStereo/NWaves.DemoStereo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="Caliburn.Micro" Version="4.0.173" />
<PackageReference Include="MaterialDesignThemes" Version="4.1.0" />
<PackageReference Include="NAudio" Version="2.0.1" />
<PackageReference Include="NWaves" Version="0.9.5" />
<PackageReference Include="NWaves" Version="0.9.6" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion NWaves.DemoUwp/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<Slider Name="FreqSlider"
Value="{Binding Freq, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
ValueChanged="MaxFreqChanged"
Minimum="500"
Minimum="800"
Maximum="5000"
Width="200"
VerticalAlignment="Center" />
Expand Down
4 changes: 2 additions & 2 deletions NWaves.DemoUwp/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public MainPage()

private async void File_Click(object sender, RoutedEventArgs e)
{
if (graph == null)
if (graph is null)
{
await CreateAudioGraph();
}
Expand Down Expand Up @@ -63,7 +63,7 @@ private async Task SelectInputFile()
filePicker.ViewMode = PickerViewMode.Thumbnail;
StorageFile file = await filePicker.PickSingleFileAsync();

if (file == null)
if (file is null)
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion NWaves.DemoUwpEffect/NWaves.DemoUwpEffect.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
<Version>6.1.5</Version>
</PackageReference>
<PackageReference Include="NWaves">
<Version>0.9.5</Version>
<Version>0.9.6</Version>
</PackageReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="NWaves">
<Version>0.9.5</Version>
<Version>0.9.6</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.MediaRouter">
<Version>1.2.0</Version>
Expand Down
74 changes: 73 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,75 @@
# NWaves.Samples

![stereo](https://github.com/ar1st0crat/NWaves.Samples/blob/main/screenshots/stereo.png)
### NWaves.DemoForms

The simplest demo app among all samples in this repo. It's just a bunch of Win Forms (for feature extraction, transforms, filtering, etc.) and can be considered as a complementary GUI-app for ```NWaves.Tests``` with visualization of signals, spectrograms, and so on. No OOD, MVVM, etc. here whatsoever. The code's as simple as possible, so that even users not familiar with modern C#/.NET ecosystem could take a look at NWaves in action.


### NWaves.DemoStereo

This app demonstrates various [stereo audio effects](https://github.com/ar1st0crat/NWaves/wiki/Stereo-effects):

- Stereo pan effect
- ITD-ILD pan effect
- Binaural pan effect

If the ```ITD-ILD``` checkbox is checked, ```ItdIldPanEffect``` will be applied. Otherwise, if HRIRs are already loaded, binaural panning will take place. Otherwise, the basic stereo panning is applied (using the pan rule selected in the corresponding combobox).

CIPIC_RIRS folder contains data from [CIPIC database](https://www.ece.ucdavis.edu/cipic/spatial-sound/hrtf-data/) (3 randomly selected subjects for demo).

In order to specify HRIRs, simply click on any file in one of the subject's folders.

<img src="https://github.com/ar1st0crat/NWaves.Samples/blob/main/screenshots/stereo.png" width="600" />


### NWaves.DemoUwp

This demo app shows how we can add NWaves audio effects, filters and block convolvers to UWP projects for online audio processing. In this example we work with ```AutowahEffect``` and allow user online-tweaking only couple of its parameters: maximum LFO frequency and Q factor.

<img src="https://github.com/ar1st0crat/NWaves.Samples/blob/main/screenshots/uwp.png" width="480" />

Most of the code simply repeats [AudioCreation UWP sample code](https://github.com/microsoft/Windows-universal-samples/tree/master/Samples/AudioCreation/cs).

Effect is added to the ```AudioGraph``` here:

```C#
private void AddCustomEffect()
{
PropertySet wahwahProperties = new PropertySet
{
{ "Max frequency", 2000f },
{ "Q", 0.5f }
};

AudioEffectDefinition wahwahDefinition =
new AudioEffectDefinition(typeof(NWavesEffect).FullName, wahwahProperties);

fileInputNode.EffectDefinitions.Add(wahwahDefinition);
}
```


According to MS documentation, custom sound effects must be implemented in separate projects as Windows runtime components. [This project contains implementation of the effect](https://github.com/ar1st0crat/NWaves.Samples/tree/main/NWaves.DemoUwpEffect).


### NWaves.DemoXamarin

This demo app shows how we can do online audio processing in Xamarin.

The app

- estimates pitch online using 2 methods (ZCR and autocorrelation)
- applies robotization effect online
- saves robotized audio to wav file on Android device

1) Launch app, 2) press "Rec" button, 3) start talking, 4) press "Stop" button, 5) check recorded file.

Robotized audio will be recorded to ```Android/media``` folder.


### More

- [NWaves.Blueprints](https://github.com/ar1st0crat/NWaves.Blueprints) (Audiograph editor (NWaves + NAudio + Caliburn.Micro))
- [NWaves.Synthesizer](https://github.com/ar1st0crat/NWaves.Synthesizer) (Guitar & organ synthesis (NWaves + NAudio + Caliburn.Micro))
- [NWaves.VoiceEffects](https://github.com/ar1st0crat/NWaves.VoiceEffects) (Morpher, Robotizer, Whisperizer (NWaves + Caliburn.Micro))
- [NWaves.Playground](https://github.com/ar1st0crat/NWaves.Playground) (NWaves + Blazor)

0 comments on commit 19afb0f

Please sign in to comment.