Recording Data into buffer~ with peek

Augustine Bannatyne - Leudar's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Hello there,
I am trying to record around 12 hours of non audio data into a buffer sampling every 50 ms so I can playback (time lapse data) later. I am finding that buffer is only recording around half an hour and then no more.
I have set the buffer size to 1000,000 and the sample rate to sr20 so twenty times a second (1000 / 50 = 20)
I figure 1,000,000 divided by 3600 (amount of seconds in an hour) / 20 (amount of 50 ms in a second) = 13.8 hours. So anyway I'm obviously going wrong somewhere , not sure if niquist needs to be considered I paste the patch below any help appreciated:

Christopher Dobrian's icon
Max Patch
Copy patch and select New From Clipboard in Max.

You appear to be confused about the arithmetic involved, as well as by the units used in the argument to buffer~.
Here's a way to think about it.
How many numbers do you need to store?
(12 hrs) * (60 min/hr) * (60 sec/min) * (20 samples/sec) = 864,000 samples
How many seconds' worth of storage do you need?
Assuming that the audio sampling rate you're using is 44.1KHz...
(864,000 samples) / (44,100 samples/sec) = 19.5918367 sec
You specify the size of a buffer in terms of the number of milliseconds' worth of samples it will hold. So...
(19.5918367 sec) * (1000 ms/sec) = 19,591.8367 ms
Therefore an object called [buffer~ mydata 20000] will be ample.
(Alternatively, you can create [buffer~ mydata], then send it a message 'sizeinsamps 864000'.)

Augustine Bannatyne - Leudar's icon

Great Christopher thanks , Ill give this a go later