LRWave Core Functions Complete
After a few hours of JavaScript coding, all the core functionality I set out to implement is running. At least, at a basic level. (This link will go to the live version of LRWave, which should continue to improve as I learn.)
- Two-channel (left and right) function generator
- Frequency adjustment
- User can type in anything from 0 to 24 kHz
- Buttons to adjust frequency up/down in 1Hz steps.
- Waveform selection available in Web Audio API
- Sine
- Square
- Sawtooth
- Triangle
- Gain adjustment
- User can type in anything from 0% to 100%
- Play/pause button.
Since I hate web pages that start playing some sound upon load without user interaction, I don't start playing sound until the user has pushed the play button. It turns out I have accidentally followed the guidance from Google, which will not allow pages using Web Audio API to play sound before user input. I don't always agree with Google, but I'm glad we're aligned here.
The JavaScript portion of this project have been relatively easy. I found Web Audio API to be straightforward to use in my simple little function generation app. There are some refinements to be made: there are audible pops as settings are updated. Right now I perform those updates immediately, but they should ramp from old to new value in order to avoid abrupt changes. Everything else dealing with user interface are standard event handler code.
What I found challenging is the aesthetics side of things. Proper HTML layout is still a struggle for me, but I know projects like this will eventual lead to mastery (or at least competence) with responsive web layout. In the meantime, my app looks fine on a phone in portrait orientation but things start to get weird quickly as browser window size grows.
Individual components in MDC Web have worked well so far, with the exception of the slider control. I tried to use it for gain but it didn't behave as I expected so, after a half an hour scratching my head, I set it aside for later. Another difficulty was MDC theming. I wanted the background to be black and I haven't found my mistake when trying to do it within MDC theming module.
On the web browser interaction side, I designed an icon and added a reference in the header. Google Chrome recognizes it enough to use the icon on the recently opened sites window, but it doesn't use the icon on the browser tab and I don't understand why.
Lots of learning so far, but more learning plus refinement ahead...