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

feat: midi #83

Merged
merged 1 commit into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.5.2
with:
fetch-depth: 0
- name: Setup Node.js and Cache
uses: ./.github/actions/nodejs

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-prerender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.5.2
with:
fetch-depth: 0
- name: Setup Node.js and Cache
uses: ./.github/actions/nodejs

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.5.2
with:
fetch-depth: 0
- name: Setup Node.js and Cache
uses: ./.github/actions/nodejs

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.5.2
with:
fetch-depth: 0
- name: Setup Node.js and Cache
uses: ./.github/actions/nodejs

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3.5.2
with:
fetch-depth: 0
- name: Setup Node.js and Cache
uses: ./.github/actions/nodejs

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.5.2
with:
fetch-depth: 0
- name: Setup Node.js and Cache
uses: ./.github/actions/nodejs

Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ jobs:
strategy:
fail-fast: false
matrix:
project: [common, resize-observer, universal, audio, canvas, geolocation]
project: [common, resize-observer, universal, audio, canvas, geolocation, intersection-observer, midi]
name: ${{ matrix.project }}
steps:
- uses: actions/checkout@v3.5.2
with:
fetch-depth: 0
- name: Setup Node.js and Cache
uses: ./.github/actions/nodejs

Expand Down Expand Up @@ -65,6 +67,16 @@ jobs:
directory: ./coverage/geolocation/
flags: summary,geolocation
name: geolocation
- uses: codecov/codecov-action@v3.1.3
with:
directory: ./coverage/midi/
flags: summary,midi
name: midi
- uses: codecov/codecov-action@v3.1.3
with:
directory: ./coverage/intersection-observer/
flags: summary,intersection-observer
name: intersection-observer
- uses: codecov/codecov-action@v3.1.3
with:
directory: ./coverage/resize-observer/
Expand Down
5 changes: 5 additions & 0 deletions apps/demo/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ export const appRoutes: Routes = [
)
).IntersectionObserverPageModule,
},
{
path: DemoPath.MidiPage,
loadChildren: async () =>
(await import(`./pages/midi/midi-page.module`)).MidiPageModule,
},
{
path: '',
redirectTo: DemoPath.HomePage,
Expand Down
1 change: 1 addition & 0 deletions apps/demo/src/app/constants/demo-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export enum DemoPath {
CanvasPage = `canvas`,
GeolocationPage = `geolocation`,
IntersectionObserverPage = `intersection-observer`,
MidiPage = `midi`,
}
3 changes: 1 addition & 2 deletions apps/demo/src/app/pages/home/home-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@ <h2>Intersection Observer</h2>
/>
</a>
<a
href="https://github.com/ng-web-apis/midi"
target="_blank"
class="link"
[routerLink]="['/', link.MidiPage]"
[class.not-supported]="!midiSupport"
>
<div>
Expand Down
39 changes: 39 additions & 0 deletions apps/demo/src/app/pages/midi/adsr.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {Pipe, PipeTransform} from '@angular/core';
import {AudioParamInput} from '@ng-web-apis/audio';

@Pipe({
name: 'adsr',
})
export class AdsrPipe implements PipeTransform {
transform(
value: number,
attack: number,
decay: number,
sustain: number,
release: number,
): AudioParamInput {
return value
? [
{
value: 0,
duration: 0,
mode: 'instant',
},
{
value,
duration: attack,
mode: 'linear',
},
{
value: sustain,
duration: decay,
mode: 'linear',
},
]
: {
value: 0,
duration: release,
mode: 'linear',
};
}
}
52 changes: 52 additions & 0 deletions apps/demo/src/app/pages/midi/demo/demo.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<ng-container *ngIf="notes$ | async as notes">
<ng-container *ngFor="let note of notes | keyvalue; trackBy: noteKey">
<ng-container *ngIf="note.value !== null">
<ng-container
waOscillatorNode
detune="5"
autoplay
[frequency]="note.key | frequency"
>
<ng-container
waGainNode
gain="0"
[gain]="note.value | adsr: 0:0.1:note.value * 0.8:1"
>
<ng-container waAudioDestinationNode></ng-container>
</ng-container>
</ng-container>
<ng-container
waOscillatorNode
type="sawtooth"
autoplay
[frequency]="note.key | frequency"
>
<ng-container
waGainNode
gain="0"
[gain]="note.value | adsr: 0:0.1:note.value * 0.8:1"
>
<ng-container
waAudioDestinationNode
(quiet)="onQuiet(note?.key)"
></ng-container>
<ng-container [waOutput]="convolver"></ng-container>
</ng-container>
</ng-container>
</ng-container>
</ng-container>
<ng-container
#convolver="AudioNode"
waConvolverNode
[buffer]="response | async"
>
<ng-container waAudioDestinationNode></ng-container>
</ng-container>

<div
*ngFor="let key of octaves"
[class]="getClass(notes, key)"
(mousedown)="onMouseDown(key)"
(touchstart)="onMouseDown(key)"
></div>
</ng-container>
Loading