What are chunks, samples and frames when using pyaudio

“RATE” is the “sampling rate”, i.e. the number of frames per second “CHUNK” is the (arbitrarily chosen) number of frames the (potentially very long) signals are split into in this example Yes, each frame will have 2 samples as “CHANNELS=2”, but the term “samples” is seldom used in this context (because it is confusing) Yes, … Read more

Take n random elements from a List?

Two main ways. Use Random#nextInt(int): List<Foo> list = createItSomehow(); Random random = new Random(); Foo foo = list.get(random.nextInt(list.size())); It’s however not guaranteed that successive n calls returns unique elements. Use Collections#shuffle(): List<Foo> list = createItSomehow(); Collections.shuffle(list); Foo foo = list.get(0); It enables you to get n unique elements by an incremented index (assuming that the … Read more