My first smartphone apps were these basic tools to allow users to create their own binaural beats. The app was called Binaural, and this past December, I made both the iOS and Android versions free for anyone to download and use. Now, I've decided to take this a step further and make the core of these apps open source! This means that you can go to my github page and download fully working sample apps that generate binaural beats and isochronic pulses. Then, you can use these algorithms in your own apps. If you find any of this useful, I'd appreciate you give me shout, and perhaps I'll feature your app on my Guided Meditation Treks blog! Here's the source code for iOS. Here's the source code for Android. Or you can just download the app and not worry about how it works! Generating Binaural Beats With a ComputerBinaural beats are simply two discrete sine waves, each played in different ears. So, all the app needed to do is to generate a sine wave of a specific frequency in one ear, then a separate sine wave of a different frequency in the other. There are many different ways to generate sine waves, depending on our operating system and how you approach the problem, but the underlying idea is still the same. All I had to do was:
Generating Isochronic Tones With A ComputerUnlike Binaural Beats, isochronic tones are a single mono sine wave. The difference is that this sine wave's amplitude is modulated across time. For example, an isochronic tone at 8hz would turn on and off 8 times per second. Therefore, the render algorithm looks a little bit different, and essentially fades the sine wave in and out very quickly. What I had to do:
Relevant Methods in iOSFor iOS, I started with some code from Matt Gallager to generate sine waves using Apple's Audio Units. This was my starting point for this app, though, in my later apps like the sleep app, I used a totally different method. Anyway, in Binaural, the audio unit is generated in the RenderTone static classes of the two viewControllers, and the actual playback of the audio unit takes place in the renderTone() method of each of the respective viewControllers. You'll notice that the algorithms of RenderTone are significantly different between Binaural Beats and Isochronic Tones, based on the explanations above, but the only major difference between the two renderTone() methods is that binaural beats uses two channels per frame, and isoChronic uses only one. Relevant Methods in AndroidFor Android, again, I started with some sample code to generate sine waves using android's AudioTrack object. Then, I made the relevant changes listed above. The android project has two relevant classes that contain the construction of these tones: Binaural.java and Isochronic.java Everything regarding the algorithms is nicely modularized in those two classes!
Here's the source code for iOS. Here's the source code for Android. Or you can just download the app and not worry about how it works!
4 Comments
Charly
3/1/2017 06:50:52 pm
So great, thank you for sharing your work :)
Reply
Chris H
12/17/2020 09:01:18 pm
Thanks for all this hard work man, appreciate it
Reply
Leave a Reply. |
RussCategories
All
Archives
October 2022
Copyright (c) 2015 Russell Eric Dobda
|