Skip to content

Commit

Permalink
Improves support for SM4s
Browse files Browse the repository at this point in the history
- Adds high precision timer support for SM4s. Fixes #330
- Adds support for microphone sensitivity reporting for Sm4s partially addressed #331
- Adds make, model, and sensor name for SM4. Partially addresses #296

- BREAKING change: resets channel identifier to match industry standard. i.e. the first channel is 0 (left). We were counting from 1 which is not the most popular format: https://en.wikipedia.org/wiki/Surround_sound#Channel_notation
- BREAKING: Fixed a bug with the Location parsing code! Coordinates from WA sensors will now report the correct hemisphere
  • Loading branch information
atruskie committed Mar 9, 2023
1 parent 7535ddf commit e8dad41
Show file tree
Hide file tree
Showing 32 changed files with 695 additions and 325 deletions.
56 changes: 28 additions & 28 deletions docs/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,46 +128,46 @@ Notes:

### Wildlife Acoustics

#### Song Meter SM4BAT

| Name | Supported | Location(s) | Notes | Field | Units |
| --------------- | --------- | ------------ | ------------ | --------- | ----- |
| Date Time | ✔️ | Name, Header | | StartDate | |
| Start Date | ✔️ | Name, Header | | StartDate | |
| Sensor Name | ✔️ | Header | | | |
| Firmware | ✔️ | Header | | | |
| Serial Number | ✔️ | Header | | | |
| Longitude | ✔️ | Header | | | |
| Latitude | ✔️ | Header | | | |
| Temperature | ✔️ | Header | | | °C |
| Battery Voltage || Support | Summary file | | |


#### Song Meter SM4

| Name | Supported | Location(s) | Notes | Field | Units |
| --------------- | --------- | ----------- | ------------ | ----- | ----- |
| Date Time | ✔️ | Header | | | |
| Sensor Name | ✔️ | Header | | | |
| Firmware | ✔️ | Header | | | |
| Serial Number | ✔️ | Header | | | |
| Longitude | ✔️ | Header | | | |
| Latitude | ✔️ | Header | | | |
| Temperature | ✔️ | Header | | | °C |
| Battery Voltage || Support | Summary file | | |
#### Song Meter SM4/SM4BAT/SM3

| Name | Supported | Location(s) | Notes | Field | Units |
| ------------------------ | --------- | ------------ | --------------------------------- | -------------- | ----------------- |
| Date Time | ✔️ | Name, Header | | LocalStartDate | |
| High Precision Date Time | ✔️ | Name, Header | | StartDate | |
| Sensor Make | ✔️ | Header | | | |
| Sensor Model | ✔️ | Header | | | |
| Sensor Name | ✔️ | Header | | | |
| Firmware | ✔️ | Header | | | |
| Serial Number | ✔️ | Header | | | |
| Longitude | ✔️ | Header | | | |
| Latitude | ✔️ | Header | | | |
| Temperature (internal) | ✔️ | Header | | | °C |
| Temperature (external) || Header | No test files currently available | | °C |
| Light || Header | No test files currently available | | Candela |
| Humidity || Header | No test files currently available | | relative humidity |
| Battery Voltage || Support | Summary file, need examples! | | |

#### Song Meter Mini

TODO: Need more example files!

| Name | Supported | Location(s) | Notes | Field | Units |
| ------------- | --------- | ----------- | ----- | ----- | ----- |
| Serial Number || Header | | | |

#### Song Meter SM3

#### Song Meter SM2

TODO: Need more example files!

### Cornell Lab

TODO: Need more example files!

#### Swift

TODO: Need more example files!

#### SwiftOne

TODO: Need more example files!
11 changes: 6 additions & 5 deletions src/Emu/Audio/Vendor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@

namespace Emu.Audio
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
using YamlDotNet.Core.Tokens;

public enum Vendor
{
[EnumMember(Value = "Unknown")]
Unknown = 0,
[EnumMember(Value = "Frontier Labs")]
FrontierLabs = 1,
[EnumMember(Value = "Wildlife Acoustics")]
WildlifeAcoustics = 2,
[EnumMember(Value = "Open Acoustics")]
OpenAcoustics = 3,
}
}
20 changes: 20 additions & 0 deletions src/Emu/Audio/VendorExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// <copyright file="Vendor.cs" company="QutEcoacoustics">
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group.
// </copyright>

namespace Emu.Audio
{
public static class VendorExtensions
{
public static string ToNiceName(this Vendor vendor)
{
return vendor switch
{
Vendor.FrontierLabs => "Frontier Labs",
Vendor.WildlifeAcoustics => "Wildlife Acoustics",
Vendor.OpenAcoustics => "Open Acoustics",
_ => "Unknown",
};
}
}
}
4 changes: 2 additions & 2 deletions src/Emu/Audio/Vendors/FrontierLabs/FrontierLabs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ public static Fin<object> LocationParser(string value)
int latLonDividingIndex = parsedValue.IndexOfAny(new char[] { '+', '-' }, 1);

// Parse lat and lon
double latitude = double.Parse(parsedValue.Substring(0, latLonDividingIndex));
double longitude = double.Parse(parsedValue.Substring(latLonDividingIndex));
double latitude = double.Parse(parsedValue[..latLonDividingIndex]);
double longitude = double.Parse(parsedValue[latLonDividingIndex..]);

location[LatitudeKey] = latitude;
location[LongitudeKey] = longitude;
Expand Down
65 changes: 65 additions & 0 deletions src/Emu/Audio/Vendors/WildlifeAcoustics/WAMD/SubChunkId.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// <copyright file="SubChunkId.cs" company="QutEcoacoustics">
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group.
// </copyright>

namespace Emu.Audio.Vendors.WildlifeAcoustics.WAMD
{
using System.Runtime.Serialization;

// from wa_meta.h
public enum SubChunkId : ushort
{
[EnumMember(Value = "METATAG_VERSION")]
Version = 0x0000,
[EnumMember(Value = "METATAG_DEV_MODEL")]
DevModel = 0x0001,
[EnumMember(Value = "METATAG_DEV_SERIAL_NUM")]
DevSerialNum = 0x0002,
[EnumMember(Value = "METATAG_SW_VERSION")]
SwVersion = 0x0003,
[EnumMember(Value = "METATAG_DEV_NAME")]
DevName = 0x0004,
[EnumMember(Value = "METATAG_FILE_START_TIME")]
FileStartTime = 0x0005,
[EnumMember(Value = "METATAG_GPS_FIRST")]
GpsFirst = 0x0006,
[EnumMember(Value = "METATAG_GPS_LAST")]
GpsTrack = 0x0007,
[EnumMember(Value = "METATAG_SOFTWARE")]
Software = 0x0008,
[EnumMember(Value = "METATAG_LICENSE_ID")]
LicenseId = 0x0009,
[EnumMember(Value = "METATAG_USER_NOTES")]
UserNotes = 0x000A,
[EnumMember(Value = "METATAG_AUTO_ID")]
AutoId = 0x000B,
[EnumMember(Value = "METATAG_ID_MANUAL")]
ManualId = 0x000C,
[EnumMember(Value = "METATAG_VOICE_NOTE")]
VoiceNote = 0x000D,
[EnumMember(Value = "METATAG_AUTO_ID_STATS")]
AutoIdStats = 0x000E,
[EnumMember(Value = "METATAG_TIME_EXPANSION")]
TimeExpansion = 0x000F,
[EnumMember(Value = "METATAG_DEV_PARAMS")]
DevParams = 0x0010,
[EnumMember(Value = "METATAG_DEV_RUNSTATE")]
DevRunstate = 0x0011,
[EnumMember(Value = "METATAG_MIC_TYPE")]
MicType = 0x0012,
[EnumMember(Value = "METATAG_MIC_SENSITIVITY")]
MicSensitivity = 0x0013,
[EnumMember(Value = "METATAG_POS_FIRST")]
PosLast = 0x0014,
[EnumMember(Value = "METATAG_TEMP_INT")]
TempInt = 0x0015,
[EnumMember(Value = "METATAG_TEMP_EXT")]
TempExt = 0x0016,
[EnumMember(Value = "METATAG_HUMIDITY")]
Humidity = 0x0017,
[EnumMember(Value = "METATAG_LIGHT")]
Light = 0x0018,
[EnumMember(Value = "METATAG_PRESSURE")]
Padding = 0xFFFF,
}
}
63 changes: 63 additions & 0 deletions src/Emu/Audio/Vendors/WildlifeAcoustics/WAMD/Wamd.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// <copyright file="Wamd.cs" company="QutEcoacoustics">
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group.
// </copyright>

namespace Emu.Audio.Vendors.WildlifeAcoustics.WAMD
{
using Emu.Models;
using LanguageExt;
using NodaTime;

public record Wamd
{
public ushort Version { get; init; }

public string DevModel { get; init; }

public string DevSerialNum { get; init; }

public string SwVersion { get; init; }

public string DevName { get; init; }

public Either<OffsetDateTime, LocalDateTime>? FileStartTime { get; init; }

public Location GpsFirst { get; init; }

public string GpsTrack { get; init; }

public string Software { get; init; }

public string LicenseId { get; init; }

public string UserNotes { get; init; }

public string AutoId { get; init; }

public string ManualId { get; init; }

public string VoiceNote { get; init; }

public string AutoIdStats { get; init; }

public ushort? TimeExpansion { get; init; }

public string DevParams { get; init; }

public string DevRunstate { get; init; }

public string[] MicType { get; init; }

public double[] MicSensitivity { get; init; }

public Location PosLast { get; init; }

public double? TempInt { get; init; }

public double? TempExt { get; init; }

public double? Humidity { get; init; }

public double? Light { get; init; }
}
}
Loading

0 comments on commit e8dad41

Please sign in to comment.