Song Title: Nothing’s Gonna Stop Us Now
Song Artist: Starship
Song Link: https://youtu.be/YR5ApYxkU-U
While I wish that this title would be accurate for the rest of the semester, I know that won’t be the case. But for this week, it is, and I’m going to enjoy my success in blissful ignorance for a little longer.
Anyway, I was able to finally figure out my issue with repositioning within the audio. As it turns out, the file reader that I was originally using to play my audio (MediaFoundationReader) doesn’t like repositioning and is what was causing me all of my issues. So, now I am using AudioFileReader in order to play the user’s audio file.
Unfortunately though, this came with some errors of its own. AudioFileReader would throw an exception when trying to play an mp3 which was not ideal as mp3 is the most common and popular audio file format. So, I did some more digging online to see if there was any way that I could work around this. There were a few sites that talked about writing the contents of the mp3 file to a memory stream and then reading it from there, but all of those used MP3FileReader which also did not want to work with any of the mp3 files I tried. I eventually decided to just have the user “convert” the mp3 into a wav file by prompting them (I’ll include a screenshot below of what the MessageBox says). This wasn’t my ideal solution, but it will have to suffice.
Additionally, now that repositioning within the audio stream is working, I was able to finish up the undo/redo functionality (FINALLY!) within the editor. Thankfully everything that I have been trying to do with MediaFoundationReader to reposition the audio worked perfectly with AudioFileReader so I only had to clean up the code a bit to get it working smoothly. I’ve included a video below as to how this looks during the editing process.
There were a few other decisions and changes that I made during this past week. The first is that I decided to make the timestamp textbox read only. I originally wanted the user to be able to change the timestamps within the textbox on their own in case they were only a little bit off on something, but after some thought, I realized that it would be really hard to validate the data that they could possibly type, and not really worth it in the grand scheme of things. But, with this change, I decided to add “-15 Seconds” and “+15 Seconds” buttons. This allows the user to jump forwards or backwards 15 seconds in the song in order to change a timestamp without completely removing it with the undo button. I’m not sure if it will stay as 15 seconds, I’ll be getting some feedback from my classmates on Thursday, but the meat of the code would stay the same if the number did change. I’ve included a video below as to how this works as well.
I’ve also have worked a little more on piecing together all of the parts, but again, there isn’t much more than just separate forms opening when buttons are pressed so I don’t have any videos or screenshots of that to share. But, hopefully by next week there will be something of that to show.
Well, that’s about it for this update. My apologizes that it is a day later than normal, but time got away from me yesterday. I’ve included some of the sites that I used over the past week below. As always, thanks for reading.
Lauren (3/29/22)
How is it almost April already?
Sites:
- c# – Convert Mp3 to WAV with naudio without writing on disk. (Stream only) – Stack Overflow (didn’t end up doing this route, but did attempt it)
- NAudio/ConvertMp3ToWav.md at master · naudio/NAudio (github.com) (What I actually used)
- C# Message Box (c-sharpcorner.com) (Message box with buttons)
- c# – Default Filename SaveFileDialog – Stack Overflow
- NAudio Output Devices (markheath.net) (Mark Heath is actually the creator of NAudio)
- The NAudio WaveStream in Depth (markheath.net)
- c# – NAudio playback position – Stack Overflow
- How do I create a seekbar in C#\NAudio Music Player? – Stack Overflow (One of the articles that made me realize it was probably my file reader that was causing me issues)
- c# – NAudio – seeking and navigation to play from the specified position – Stack Overflow (And this one)
- NAudio: How to accurately get the current play location when changing play position using AudioFileReader and WaveOutEvent – Stack Overflow (And this one)
Lots of articles that I just used as research as to why things weren’t working!
Videos && Screenshots
No responses yet