 We list all the magic numbers in all the pieces of code provided above. Okay, so we have those in Python script, magic numbers, actually not magic numbers. I'll leave those alone. In the index HTML we have levels going up to 10, we actually want to test this going up to double that. Let's see what difference to the noise reduction it does makes now in JavaScript. Yeah, those ones. The volume and duration, we want to either control automatically or have controller sliders on the front page. We can leave it there first. That's for sampling frequency and that should be fine. And we have this focusing on volume and duration. In fact, we just remembered that we might have already done. So we want to control volume, we want to link volume to the whole spectrum, the energy of the whole spectrum. And the volume it set to default. Essentially the idea is to control the volume by the whole spectrum, even though it might be problematic. So we have this seizure in this recording, so it might be just very soft before and after the seizure. If we map amplitude to the power in the whole spectrum, it would just become very loud during seizure over there. So before seizure we have the power going up to 500 and during seizure it's going up to 8,000. Just the effect of the different window size. This power number should really be, we do normalize it somewhere from 0 to 1. That's not what displayed on screen. So if you have any ideas of how to map, how to control the volume, the volume at the moment is always the same. The other option is to just give the user control of volume and duration. Focusing on volume and duration, we would like to have two options. I would the user select the raw, the actual value of each using an input on the front panel. We also want an option to automate volume and duration. For example, we might link volume to the power in the whole spectrum of the EEG and duration could be linked to the window size. If this code is not enough, it's not going to do the whole thing on the front page. So all those are available in another application. So put them down at the bottom. So everything from a window to noise. Calling it music cannot sound because we're actually using musical notes, musical notation. Turn whole spectrum back on by default. Control I, turn on by default. It should be a simple task for a GitHub copilot. We'll split the controls into two sections. So it's already split. Why is the noise below the bottom? The chart is the same as the whole spectrum. Right, so we have changed the label, EEG to music, channel number, select the channel number, the window size. Makes a big difference. And the file scroller is the main controller. And under this scroll, we want another control. We have volume and duration and some default values. We have these two switches as well. So what they look like. Right, so we have the volume doesn't really fit the screen. Maybe it should look like this. Should we turn it on by default? Well, let's try the manual volume control first. Currently, it's all the same volume. You can get values from the HTML into the JavaScript code and the calculate. So we need another function. So volume should be linked to the whole spectrum. So we need those two functions. The EEG power in the whole spectrum should be this value here. So the idea is when you can set the volume manually. Maybe if you do, if you touch this scroller, the toggle button should turn off. We don't have it yet, but that could be better way of implementing it. When you turn it on, it should take the overall energy for the whole spectrum. So I see it would be a problem with this, but give it a go. Unlike it, you could just set your own volume manually. For duration, we're linking the duration of each node being played to either manually. You could set it manually, or if it's a turn, auto-duration will be linking the duration of each node being played to the window size, which you can change yourself. Instead of an additional function play sound, can we just modify the play frequency function that takes frequency, volume, and duration as inputs? Right, so now we're taking more inputs, auto-volume, auto-duration. Okay, do we need all that? I don't think so. High frequency. Definitely don't need the EEG data, because we already have the frequency. Why do we need the EEG data? That's odd. Okay, one of the two new functions calls. So we definitely need this to calculate auto-volume. It is two functions, calculate auto-volume, and calculate auto-duration. One, the play frequency function that takes volume, duration is play frequency, play frequency, use this to, oh no, and it's, I don't know, because it's not having the whole context. You have to actually, how the GitHub co-pilot works, but you can actually select the whole code and ask this question again. Yeah, so then now looking at the 200 lines of code. Yeah, I suspect GitHub co-pilot won't be able to do it. And what was the problem with GPT? Why do we need to input the EEG data? We can actually calculate volume. Okay, maybe the original idea wasn't too bad. Yeah, problem now is that play sound is not being actually called. So those are default values. Play sound is currently not being used. Mate suggests the changes. Yeah, so I assume instead of play frequency, it should be play sound. And this is not taking any parameters, is it? Oh, it's not taking any parameters. Just essentially calling play frequency and yeah, I'm taking the manual volume or taking the automated volume, which then be taken from the whole spectrum energy in that particular window. And that's normalized. We only have two places where the play sound doesn't work anymore. Frequency is not defined, should take frequency as input, must be the order making frequency global variable. Yeah, we need the frequency as an input for sense. The volume, the auto volume does not work. Right, actually auto duration does work. So if you probably should make it so when you use this scroller, that's manual by default. Right, so this duration does work manually. It's still playing the previous one. It's actually this problem. I'm pretty sure I told it not to play when another note is playing. Stop playing the previous one. It's obviously not doing it because when we increase this duration, so now it's playing short notes, which is fine. Put it roughly in the middle. Yeah, it starts playing them on top of one another. So I can play a long one. Still playing the previous one. Let me do this auto duration. It should be no, actually it should be grayed out. And this value should indicate what's currently being used. And it should essentially be linked to that number. It works pretty well. Rising me. Okay, it's pretty annoying. It can be quite annoying, but I might let you play with it. But the auto volume does not work. You know, when auto duration is selected, something should happen to this one. Should be grayed out and showing what's the current value is. Okay, it's working well. It is working well. However, we want to make a few more adjustments. For example, when auto duration is on, the duration seconds scroller should be grayed out. And ideally, indicating the current value when this should be the case for auto volume as well. That doesn't work at the moment. Yeah, it's getting grayed out as requested. Make this grayed out where you still change when I change the window size. So need the window size input. Right, so this is happening when we start. Expect that to change. Oh, it is changing, but only after... Yeah, that's about there. Yeah, volume is the tricky business. Yeah, the auto volume, it doesn't work. Oh, wait a second. If it's checked, so if it's turned on, duration disabled true, duration input value. Oh, I do need to do that, but where do I do that? Something is wrong. I don't need to do this again. Yeah, don't see why I need this again, because we're really doing this in the event listener. But that's all right. So event listener is only doing it when the change occurs. If it's checked, if it's turned on. No, it can't make sense. It's not working. So this very should be recalculated and updated. Disable it after it's being updated. Anyway, that's the duration. And if it's automated, that's linked to the window size. There's a little bug there, but that should be okay. Now with the volume, I have volume zero. It's volume one. Obviously it will become super loud if I keep going. So first need to check a volume input. I don't know why is it, it's from zero to one and steps of 0.01. But play the same, same. Right, so this volume is going from zero to one in this tiny steps, which is a bit odd. Anything should be 0.1 or something. A couple of issues with the volume. First, it seems like it's getting way too loud. Should the maximum volume be reduced to 10 volt or something? The second problem is that auto volume doesn't work. It gives the following error. Let's actually check what the error is. Some reference is not defined, but it gives this following error. So the volume seems to be okay. I don't want to play it too loud at the moment. Calculating the auto volume, okay. How do I do that? Look like auto volume will be within the new range. I assume so. Some reference, but okay. No, this meant to be some reference, but no, no. The eG data should have the power of the whole spectrum. This is what being displayed. Over here, whole spectrum, whole spectrum toggle, fetch data and render function. It's a long function. How do I fetch the whole spectrum? Okay, this now we know what the problem is. That the average power, it's not an average power. It should be in the data. The sum reference power should be the value of the whole spectrum power that should be available in the eG data. Calculate auto volume, that makes sense. Why we're calculating it though? Well, right, because we have the multiple data values. So yes, we're calculating the average for it. Here we have the auto power. Has it got some reference power? Now average power makes more sense. And what's going wrong is the fact that this spectrum should have already contained everything we need. The auto duration works okay, but volume doesn't. I assume we're getting this error. And we're not getting that error. Okay, this was sick. Yeah, the sum reference power is not defined. Assuming eG data spectrum does exist. It's the whole eG data in the log. Let's see eG data in zero signals as in spectrums. On spectrums, right. So in spectrums, we already have whole spectrum. So we cheat that as spectrums, as whole spectrum, it's the one. Use whole spectrum to calculate the volume. Is it finding the spectrum there? Yeah, don't get this average power. Don't get it. Now over here, the total power is not being used. This one makes a lot more sense to return the volume and look at the volume to console. Going auto volume. Yeah, that's interesting. I don't know if you can hear anything, probably not. The volume is too low and too work. It's working in a sense that it's much lower when there's no seizure. Is it? No. So taking alpha, yeah, the problem is it has some max power. It's 100, it said to work okay. Yeah, I don't like this magic number, but it works. Should try this one. Yeah, for calculating auto volume, total power is not actually being used. So we want to use total power instead of average power. Okay, call this out. Now I think it's volume of one is obviously too large. It's like this large number like 1000. Okay, that's still too large. All right, so this volume, this magic number, volume is better. Yeah, the seizure is much louder on this channel. So you will have loudness cues for this. Check if it's okay or not. So you can decide if you're doing auto volume or not. And we will continue next time. So yeah, bye.