The cassette player gives an error "error mmapping file" when switching from record to play, without having recorded a file.
This can be easily solved by adding a
if (getState() == RECORD) removeTape(time); // flush recorded tape
at the beginning of playTape, but that will leave a valid WAV file without any content in the player. This is a useless situation: there's nothing on the tape and you can't record to it either.
So, the wanted behaviour is that the file is either not created at all or erased when nothing as written to it. The latter is better than lazy creation, to avoid problems with error situations.
After retesting: the problem doesn't occur in this scenario:
- cassetteplayer new
- cassetteplayer play
This will apparently remove the created wav file in the first step and leaves you with an empty cassetteplayer, which is great.
But if you do this:
- type in basic: LOAD"CAS:"
- cassetteplayer new
- cassetteplayer play
you do end up with an empty wav image in the cassetteplayer (at the end of the tape). The empty wav file is still 7 seconds long, though!
This is very strange and is not expected behaviour. I do admit the scenario is a bit out of the ordinary....