# Need experts to review my post on Ionic + Web Audio API

**URL:** <https://forum.ionicframework.com/t/need-experts-to-review-my-post-on-ionic-web-audio-api/19689>\
**Category:** uncategorized\
**Created:** [March 25, 2015, 3:58am UTC](https://forum.ionicframework.com/t/need-experts-to-review-my-post-on-ionic-web-audio-api/19689 "2015-03-25T03:58:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![CyberFerret](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/cyberferret/32/72111_2.png) [@CyberFerret](https://forum.ionicframework.com/u/CyberFerret)\
**Post date:** [March 25, 2015, 3:58am UTC](https://forum.ionicframework.com/t/need-experts-to-review-my-post-on-ionic-web-audio-api/19689/1 "2015-03-25T03:58:30Z")

</div>

Hey all,

Just calling out any javascript/Ionic/WebAudio experts out there who would like to review my recent post on AirPair regarding using the Web Audio API within Ionic?

I used Web Audio in a recent Ionic project of mine which is now in the App Stores, and thought that it might be useful to talk about the steps I went through, so that it would be easier for anyone else who wanted to go down this path using Ionic in the future.

My article is at: [https://www.airpair.com/posts/review/550805316912810c007d50f1](https://www.airpair.com/posts/review/550805316912810c007d50f1) and is currently not published as it needs some expert eyes to review it for accuracy and quality. If anyone here has time, I would appreciate it if you could cast your eyes over my post and give me some constructive feedback.

Cheers,  
Devan

---

<div class="post-metadata">

**Author:** ![kinhunt](https://avatars.discourse-cdn.com/v4/letter/k/82dd89/32.png) [@kinhunt](https://forum.ionicframework.com/u/kinhunt)\
**Post date:** [March 25, 2015, 4:05am UTC](https://forum.ionicframework.com/t/need-experts-to-review-my-post-on-ionic-web-audio-api/19689/2 "2015-03-25T04:05:07Z")

</div>

Good one, very informative.

---

<div class="post-metadata">

**Author:** ![bengtler](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/bengtler/32/98565_2.png) [@bengtler](https://forum.ionicframework.com/u/bengtler)\
**Post date:** [March 25, 2015, 7:13am UTC](https://forum.ionicframework.com/t/need-experts-to-review-my-post-on-ionic-web-audio-api/19689/3 "2015-03-25T07:13:43Z")

</div>

your metronomClick function is not needed on the scope ;).  
Define a simple javascript function instead.

Try to avoid polluting scopes with stuff that is not needed there.

Another hint:

```
angular.module('AudioTest', [])
  .controller('MetronomeCtrl', function($scope, $timeout) {

```

if you are loading stuff please inject them first (it is necessary if you want to minify your code).

```
angular.module('AudioTest', [])
 .controller('MetronomeCtrl', ['$scope', '$timeout', function($scope, $timeout) {

```

For angular providers this is not necessary but i think it is better to learn this correct and to know why and how i can inject things.  
The same in your run block.

Something like: “first inject them and then use them” 😄  
But thats are all trivial stuff and only suggestions of mine… i want that other peaple learn that correct.

But why you are putting all the metronom stuff on the $rootScope?  
And keep in mind that loading the file is async… if your call prepareMetronome before the file is loaded -\> you will get javascript execeptions.

I would build this whole initial process in a service.  
and hold all metronom functions there.

there would be a function like “initMetronom” which is a promise function and resolves if the file is correct loaded or onerror it will rejected.

All in all it is well written article.

---

<div class="post-metadata">

**Author:** ![CyberFerret](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/cyberferret/32/72111_2.png) [@CyberFerret](https://forum.ionicframework.com/u/CyberFerret)\
**Post date:** [March 25, 2015, 7:25am UTC](https://forum.ionicframework.com/t/need-experts-to-review-my-post-on-ionic-web-audio-api/19689/4 "2015-03-25T07:25:02Z")

</div>

Superb feedback @bengtler - thank you so much for your very useful input.

Yes, I know in a perfect world, the Metronome functionality would be put in a Service, but this was really a quick, hacked together example.

I may break up the examples a bit more and perhaps create a Controller for the view, and that way use `$scope` instead of `$rootScope` everywhere. Unless of course it is possible to inject `$scope` into my `app.js` when not using a controller? I seem to remember trying that, but it kept throwing an error.

Cheers,  
Devan

---

<div class="post-metadata">

**Author:** ![bengtler](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/bengtler/32/98565_2.png) [@bengtler](https://forum.ionicframework.com/u/bengtler)\
**Post date:** [March 25, 2015, 7:40am UTC](https://forum.ionicframework.com/t/need-experts-to-review-my-post-on-ionic-web-audio-api/19689/5 "2015-03-25T07:40:41Z")

</div>

in a “run” block you have no “scope” so you can not inject it ;).

$scopes are only present in stuff connected with dom for databinding. (so in controllers, directives).

---

<div class="post-metadata">

**Author:** ![CyberFerret](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/cyberferret/32/72111_2.png) [@CyberFerret](https://forum.ionicframework.com/u/CyberFerret)\
**Post date:** [March 25, 2015, 7:45am UTC](https://forum.ionicframework.com/t/need-experts-to-review-my-post-on-ionic-web-audio-api/19689/6 "2015-03-25T07:45:28Z")

</div>

Yes, that is what I thought too - that’s why the only I could figure out how to bind the view controls to the code was to use `$rootScope`. In my actual app, the metronome is in a controller, so I could use `$scope` there.

---

<div class="post-metadata">

**Author:** ![bengtler](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/bengtler/32/98565_2.png) [@bengtler](https://forum.ionicframework.com/u/bengtler)\
**Post date:** [March 25, 2015, 8:50am UTC](https://forum.ionicframework.com/t/need-experts-to-review-my-post-on-ionic-web-audio-api/19689/7 "2015-03-25T08:50:34Z")

</div>

Yep and for those purposes you can work with services/factories … because they can share data through controllers 😉

---

<div class="post-metadata">

**Author:** ![sejoley194](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@sejoley194](https://forum.ionicframework.com/u/sejoley194)\
**Post date:** [August 8, 2022, 1:16pm UTC](https://forum.ionicframework.com/t/need-experts-to-review-my-post-on-ionic-web-audio-api/19689/11 "2022-08-08T13:16:40Z")

</div>

[https://forum.ionicframework.com/t/need-experts-to-review-my-post-on-ionic-web-audio-api/19689](https://forum.ionicframework.com/t/need-experts-to-review-my-post-on-ionic-web-audio-api/19689)

Thanks for sharing[!](https://forum.ionicframework.com/t/need-experts-to-review-my-post-on-ionic-web-audio-api/19689)
