Skip to content

Commit

Permalink
Changes to standard spectrogram config file
Browse files Browse the repository at this point in the history
For drawing standard spectrograms.
Also some minor changes to Audio2Sonogram.cs class.
  • Loading branch information
towsey committed Dec 6, 2019
1 parent b160627 commit b93a667
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
36 changes: 23 additions & 13 deletions src/AnalysisConfigFiles/Towsey.Sonogram.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,47 @@
---
AnalysisName: Towsey.SpectrogramGenerator
#SegmentDuration: units=seconds, SegmentOverlap=seconds

# Generate multiple standard-scale spectrogram images and oscillations info

# Usage: AnalysisPrograms.exe Audio2Sonogram [arguments] [options]
#Arguments:
# Source: The source audio file to operate on
# Config The path to this config file. If not found it will attempt to use a default config file of the same name.
# Output A directory to write output

#Following segmentation parameters are default and should usually not be changed. Units are seconds.
SegmentDuration: 60
SegmentOverlap: 0

#Resample rate must be 2 X the desired Nyquist.
ResampleRate: 22050
# WARNING: The default SR = 22050.
# IF you want to keep the recording SR AND it is NOT 22050, THEN you must set the ResampleRate value here
# ResampleRate: 20000

#FRAME LENGTH in samples - must be power of 2
FrameLength: 512
# Following frame step yields 50 frames/s which can make some subsequent operations a bit easier.
FrameStep: 441

#Frame Overlap as fraction: default=0.0
FrameOverlap: 0.25

#Resample rate must be 2 X the desired Nyquist.
# WARNING: Default SR used to be the SR of the recording. NOW DEFAULT = 22050.
# IF you want to keep the recording SR AND it is NOT 22050, THEN you must set the ResampleRate value here
# ResampleRate: 20000
Waveform: true
PowerSpectrogram: true
DecibelSpectrogram: true
PowerSpectrogram_NoiseReduced: true
PowerSpectrogram_Annotated: true
AmplitudeSpectrogram_LocalContrastNormalisation: true

#NOISE REDUCTION PARAMETERS
DoNoiseReduction: true
NoiseReductionType: Standard
BgNoiseThreshold: 3.0
LcnContrastLevel: 0.4


AddAxes: true
AddSegmentationTrack: true
VOCAL_GAP: 0.1
MIN_VOCAL_DURATION: 0.1

# REDUCTION FACTORS for freq and time dimensions
#TimeReductionFactor: 1
#FreqReductionFactor: 1

MakeSoxSonogram: false
SonogramTitle: Sonogram
SonogramComment: "Sonogram produced using SOX"
Expand Down
18 changes: 6 additions & 12 deletions src/AnalysisPrograms/Audio2Sonogram.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Audio2Sonogram.cs" company="QutEcoacoustics">
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
Expand All @@ -22,24 +22,22 @@ namespace AnalysisPrograms
using Acoustics.Shared;
using Acoustics.Shared.ConfigFile;
using Acoustics.Shared.Csv;
using Acoustics.Tools.Wav;
using AnalysisBase;
using AnalysisBase.ResultBases;
using AnalysisPrograms.Production;
using AnalysisPrograms.Production.Arguments;
using AnalysisPrograms.Production.Validation;
using AudioAnalysisTools;
using AudioAnalysisTools.DSP;
using AudioAnalysisTools.StandardSpectrograms;
using AudioAnalysisTools.WavTools;
using log4net;
using MathNet.Numerics;
using McMaster.Extensions.CommandLineUtils;
using Production;
using Production.Arguments;
using Production.Validation;
using TowseyLibrary;

/// <summary>
/// 3. Produces a sonogram from an audio file - EITHER custom OR via SOX
/// Signed off: Michael Towsey 31st July 2012
/// Produces standard greyscale spectrograms of various types from a wav audio file - EITHER custom OR via SOX.
/// </summary>
public class Audio2Sonogram
{
Expand Down Expand Up @@ -88,7 +86,7 @@ public static void Main(Arguments arguments)

var offsetsProvided = arguments.StartOffset.HasValue && arguments.EndOffset.HasValue;

// set default offsets - only use defaults if not provided in argments list
// set default offsets - only use defaults if not provided in arguments list
TimeSpan? startOffset = null;
TimeSpan? endOffset = null;
if (offsetsProvided)
Expand Down Expand Up @@ -143,10 +141,6 @@ private static Dictionary<string, string> GetConfigDictionary(FileInfo configFil
[AnalysisKeys.AddSegmentationTrack] = (configuration.GetBoolOrNull(AnalysisKeys.AddSegmentationTrack) ?? true).ToString(),
};

// # REDUCTION FACTORS for freq and time dimensions
// #TimeReductionFactor: 1
// #FreqReductionFactor: 1

bool makeSoxSonogram = configuration.GetBoolOrNull(AnalysisKeys.MakeSoxSonogram) ?? false;
configDict[AnalysisKeys.SonogramTitle] = configuration[AnalysisKeys.SonogramTitle] ?? "Sonogram";
configDict[AnalysisKeys.SonogramComment] = configuration[AnalysisKeys.SonogramComment] ?? "Sonogram produced using SOX";
Expand Down

0 comments on commit b93a667

Please sign in to comment.