piper-audio / ugly-duckling

Technology demo for Piper components using Waves-UI
4 stars 0 forks source link

Add Regions support #48

Open cannam opened 7 years ago

cannam commented 7 years ago

Per #47 and the documentation at #46, add support for "regions" outputs, i.e. outputs that are structurally rather like notes but that lack the identifying RDF metadata or units necessary to be identified as representing note tracks.

cannam commented 7 years ago

(In branch feature/regions)

First I sprinkled the logic throughout FeatureUtilities to add a region type, identify appropriate feature data, and convert & return it. That's phase 1 done.

Next, the Angular stuff.

We need a new case block in analysis-item.component.html. For the moment I've copy-pasted this from the notes case, changing note to region throughout.

Now, something needs to define the new ugly-regions selector that we thus refer to. So I copy-paste app/visualisations/notes/notes.component.ts to regions/regions.component.ts, do a similar notes-to-regions replacement, and rewrite findVerticalRange to use unitless values. I don't expect this to work yet, because it's still creating a piano-roll layer, which looks for pitch values which our new regions don't have. But it should compile and load.

It doesn't, though. It compiles, but on page load I get errors in the console:

Error: Template parse errors:
Binding to event property 'onSeek' is disallowed for security reasons, please use (Seek)=...
If 'onSeek' is a directive input, make sure the directive is imported by the current module. ("
              [timeline]="timeline"
              [width]="contentWidth"
              [ERROR ->][onSeek]="onSeek"
              [notes]="item.collected"
              [duration]="getDuration()"
"): ng:///AppModule/AnalysisItemComponent.html@89:14
Can't bind to 'colour' since it isn't a known property of 'ugly-regions'.
1. If 'ugly-regions' is an Angular component and it has 'colour' input, then verify that it is part of this module.
2. If 'ugly-regions' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
[etc]

I am guessing this means that my new regions/regions.component.ts needs to be imported somewhere. Grepping around a bit, it looks like that place is app.module.ts in the top-level src/app directory. I go in there, import the RegionsComponent, and include it in the @NgModule declaration further down.

The page now loads, and when I run the "Notes or Regions" output of the test plugin, I get the following meaningless output.

screenshot_2017-07-20_16-12-29

I sit back in satisfaction, revelling in my copy-and-paste powers.

Phase 2 is complete.

cannam commented 7 years ago

Added a region layer helper in Waves UI, using the annotated-segment shape; used it for the regions component.