Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements basic importer for Audacity project files #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

cofiem
Copy link

@cofiem cofiem commented Mar 18, 2021

File extension .aup.

Includes deserializing and loading expectations.
Includes basic tests.

Initial step for #1.

…aup.

Includes deserializing and loading expectations.
Includes basic tests.
Copy link
Member

@atruskie atruskie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So confirm for me: should there be one audacity project file per audio file?
And are those project files required to have the same name as the audio file?

If not, then we'll need to rethink the structure of this a bit. If so, see comments

Also I'm going to guess you didn't run the app? Unless I'm mistaken not enough of the new services were registered in the DI system.

Otherwise, excellent 😁

src/Egret.Cli/Serialization/Audacity/AudacityImporter.cs Outdated Show resolved Hide resolved
{
if (context.Include.Filter is not null)
{
throw new Exception("The Audacity importer does not currently support include filters");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's nothing useful to filter on in avianz data files, but you could filter the different audacity tracks by name?

Name = name,
};
}))
.ToList() ?? new List<IExpectation> {new NoEvents()};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to avoid the allocation of the list here

src/Egret.Cli/Serialization/Audacity/AudacityImporter.cs Outdated Show resolved Hide resolved

logger.LogTrace("Data file converted to expectations: {@expectations}", expectations);

yield return new TestCase {SourceInfo = dataFile?.SourceInfo, Expect = expectations.ToArray(),};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dataFile should never be null right? If it is, then we should fall back to providing some source info (like the path) so in error cases at least we can print a message that point to the right source file.

test_suites:
host_suite:
tests:
- file: bird*.wav
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line of the config should be redundant

in an abstract sense: the main egret config is importing other tests (e.g. from another egret file, or an aup file acting like an egret file) and those tests should be referencing audio files.


var tests = testsCases[0].Expect;

tests[0].Should().BeOfType<BoundedExpectation>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generated test should have it's File property set, test that


logger.LogTrace("Data file converted to expectations: {@expectations}", expectations);

yield return new TestCase {SourceInfo = dataFile?.SourceInfo, Expect = expectations.ToArray(),};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The File property is not set - it must be set. The assumption here is that the importer knows which file the metadata is referring too.

Note to self: should probably make TestCase throw if both File and Url are null or empty

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in

File = Path.GetRelativePath(Path.GetDirectoryName(path), testFile),

…entation.

Registered relevant classes as services.
Improved tests.
Made XmlSerializer work as a service.
Copy link
Member

@atruskie atruskie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there seems to be no strong link between audacity projects and audio files we're going to enforce a convention.

The file /123/abc.wav is related to the file /123/abc.aup or /123/abc.aup3 IFF the directory and basename are equivalent (i.e. they are siblings). When outputting results a source of /123/abc.wav will produce /output/abc.aup.

It appears the formatter already does this.

I think you should remove the entity framework package. The audacity3 serializer even only uses Microsoft.Data.Sqlite which AFAIK is its own package.

Probably only need one audacity importer (it can switch which serializer it uses based on file extension). As far as I can tell, the two importers do the same thing?

docs/audacity.md Show resolved Hide resolved
docs/audacity.md Outdated Show resolved Hide resolved
docs/audacity.md Outdated Show resolved Hide resolved
docs/audacity.md Outdated Show resolved Hide resolved
src/Egret.Cli/Egret.Cli.csproj Outdated Show resolved Hide resolved
src/Egret.Cli/Program.cs Outdated Show resolved Hide resolved
Comment on lines 129 to 131
// TODO: audacity projects can store audio files with the project file,
// but the audio files are split into multiple smaller files.
// File = Path.GetRelativePath(Path.GetDirectoryName(path), testFile)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See summary comments - we should find a source file with a similar name next to the project file, or fail

src/Egret.Cli/Serialization/Audacity/Audacity3Importer.cs Outdated Show resolved Hide resolved
tests/Egret.Tests/Egret.Tests.csproj Outdated Show resolved Hide resolved
Comment on lines +92 to +95
var testsCases = includeTests.Tests;
testsCases.ToList().Should().HaveCount(1);

var expectations = testsCases[0].Expect;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should assert test's source is set correctly

Addressed feedback - audio file convention, single importer, moved fixture data.
Partial implementation of audacity result formatter.
@cofiem
Copy link
Author

cofiem commented Apr 6, 2021

I'm now able to run egret with audacity project files as input, and get audacity files as output!

I'm not sure about how to write the results to the Audacity Project Tracks and labels - there's a few TODOs in there that will need your help @atruskie.

I've made the second round of changes to address your feedback. Ready for another review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants