How do I save the SoundRecorder component files in numbered order?

I entered all the blocks in the event When SoundRecorder .Stopped Recording" and now sorts them by numbering but a new number is added to each new saved file:

Also you can store the number in tiny db and get it on screen initialize so recording won’t be replaced when reopening the application as it will restart the numbering from 0

Can you post your relevant blocks so we can hep you…Did you make what @Taifun and @Soham_Shah told you…

Sorry to steal all this time, unfortunately I’m trying to learn.

When you record for the first time you set the file name for example to recording1 then you set it the next time to recoding12 as you are joining the file name which you already set…Summary :When you are joining the file name with the math you join the old one as well which is recording1 so it results recording12…

How to solve it?

Put a setter block to set the file name to “Recording” again after setting the save recording property

1 Like
2 Likes
  1. count before starting
  2. add the math vairable into the join to get the final filename and set the property SavedRecording before starting

Taifun

2 Likes

Ok, the files are saved and sorted correctly with numbering … when the app is restarted, when I start a new recording, the old files are replaced with the new ones. For this problem I can insert a TinyDB, right? Thank you all for the help you have given me and for your patience. :sweat_smile:

Right You can see my comment :

1 Like

Hi everyone, I’m Ragnarok , I created a new account and this old one is in the process of being deleted. I noticed a small problem with the recorder: When I go to delete a recording and create a new one, the latter instead of replacing the deleted one, continues the numbering order … it is possible to create a sort of “mechanism” to solve the problem?

Example:

Recording1
Recording2 (file deleted or renamed)

The next registration is Recording3 but, since Recording2 has been deleted or renamed by the user, Recording3 will become Recording2 and after which the numbering order will be resumed (Recording4, Recording5 etc.)

1 Like

That could be implemented…
Try this:


That is a for loop that will check if all of the files that is recorded by the application is exists ( not deleted )…If it exists it will set the OldFileFound to false…Else it will set it to true…Set saved recording to sound{number} so if a file deleted it will be replaced and break the loop…When the loop end it will check if OldFileFound is equal to false…If its equal to false it will save the file to the new name…And increase the global number variable by 1…
Don’t forget to change the path in exists block to your file pathes…
Eg.:
If we have recording 1 and 2 and 3…
If i deleted recording1…If you created a new recording its will be 1…Then the next time the number will be 4 ( to complete the order )…

2 Likes

I will first initialize a local variable = 0, then inside use while test file exist, add 1 to a variable. After while test, save recording using the local variable

1 Like

Your way has only one problem…If two sounds are recorded they will be with the same name…Any way its better that it will work without tiny dbd which can be removed in any time by clearing cache…

1 Like

So I have to create the following procedure block and call it in the “StartRecording” button block?

Yes you need to call it when ever you want to save a recording…Don’t forgot to store the number in tiny db while saving…

Do I need to make any changes to the following block before calling the procedure block?

:one: Remove the saved recording block…
:two:Also the math var will be increased in the procedure…
:three:You will need to put store value method inside the procedure…

When I try to start the recorder it gives me “ERROR 802: Cannot start recording: null”. Did I make a mistake in inserting any blocks?

It looks that the procedure is right… please Show me your blocks for starting recording

Annotazione 2020-08-16 141011