Body: <p>I have a .csv file with information about a soundtrack and it is divided into beats (per minute), which are ordered by row. As in: the index corresponds to each beat, and the columns have info about what is going on in each beat. The idea is to train a model to be able to infer similar data from any given song following the example of the .csv. [EDIT] Take into account that, in this specific case, the beats per minute do not vary in length, but rather, have a constant, fixed time in each song. The BPM may vary between songs but not <em>within</em> them.</p>
  <p>I already have tried some different ways to make a spectrogram. Now, I need to divide it into beat-sized chunks to train a deep neural network.</p>
  <p>I used the librosa.core.spectrum to create a logarithmic spectrogram out of a .wav file. I have tried looking for tutorials on how to use spectrograms to train DNNs but they already have separated sound files which they then convert into a spectrogram. Or else they cite papers with a close solution with no code given (take into account that I am a Python beginner).</p>
  <p>I need to take a spectrogram and divide it into chunks the size and duration of a beat (total number of beats = beats per minute multiplied by the length of the song), but I don't know where to begin looking for guidance on that process.</p>
  <p>Unless there's a different way to relate each beat in the .csv to each segment of the spectrogram? What would you recommend?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-19T15:17:58.140Z
Comments.Text: How complex is the relationship between time and musical beat in your training data in general? If it's all modern dance, rock, pop, and without any timing-affecting expression like ritardo, accelerando, pauses or free expression, then your task can maybe be handled with relatively simple tools. But a lot of real music won't fit that
Comments.UserDisplayName: Neil Slater
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-20T08:07:55.117Z
Comments.Text: @NeilSlater Not complex at all. It is almost abstract. Specific colors and off-on commands for a lamp, fog machine activation, and so on. It is less about the music itself and more about what happens at certain points of the song at the night club.
Comments.UserDisplayName: Johnathan Smitherton
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-20T08:13:46.520Z
Comments.Text: That sounds like your data per beat is simple, but not quite what I was asking. Does each piece of music have a fixed and precise timing, with little flexibility? E.g. electronic dance music written on a sequencer with a fixed bpm per song would have simple and precise timing, whilst a recording of an orchestral piece performed by humans probably would not. Extracting beat timings will be a lot easier and simpler in the former case.
Comments.UserDisplayName: Neil Slater
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-05-20T08:27:11.427Z
Comments.Text: @Neil Slater Ah, sorry about the confusion. No, no tempo rubato, no change in tempo, no pauses, no variation in speed and no variation in beat length. In this specific case, BPM is less about musical tempo and more of a technician's hack to slice time in regular intervals for the sake of data entry.
Comments.UserDisplayName: Johnathan Smitherton
Tags: <machine-learning><deep-learning><python><audio-processing>
Title: Segment a spectrogram into a series of images by (constant) beats per minute to train a Deep Neural Network
UserDisplayName: Johnathan Smitherton
ThreadText: # Segment a spectrogram into a series of images by (constant) beats per minute to train a Deep Neural Network
  
  (Asked by: username_0 on 2024-05-19)
  
  I have a .csv file with information about a soundtrack and it is divided into beats (per minute), which are ordered by row. As in: the index corresponds to each beat, and the columns have info about what is going on in each beat. The idea is to train a model to be able to infer similar data from any given song following the example of the .csv. [EDIT] Take into account that, in this specific case, the beats per minute do not vary in length, but rather, have a constant, fixed time in each song. The BPM may vary between songs but not *within* them.
  
  I already have tried some different ways to make a spectrogram. Now, I need to divide it into beat-sized chunks to train a deep neural network.
  
  I used the librosa.core.spectrum to create a logarithmic spectrogram out of a .wav file. I have tried looking for tutorials on how to use spectrograms to train DNNs but they already have separated sound files which they then convert into a spectrogram. Or else they cite papers with a close solution with no code given (take into account that I am a Python beginner).
  
  I need to take a spectrogram and divide it into chunks the size and duration of a beat (total number of beats = beats per minute multiplied by the length of the song), but I don't know where to begin looking for guidance on that process.
  
  Unless there's a different way to relate each beat in the .csv to each segment of the spectrogram? What would you recommend?
  
  **Tags:** machine-learning, deep-learning, python, audio-processing
  > **Comments:**
  > **username_1**: How complex is the relationship between time and musical beat in your training data in general? If it's all modern dance, rock, pop, and without any timing-affecting expression like ritardo, accelerando, pauses or free expression, then your task can maybe be handled with relatively simple tools. But a lot of real music won't fit that  
  > **username_0**: @NeilSlater Not complex at all. It is almost abstract. Specific colors and off-on commands for a lamp, fog machine activation, and so on. It is less about the music itself and more about what happens at certain points of the song at the night club.  
  > **username_1**: That sounds like your data per beat is simple, but not quite what I was asking. Does each piece of music have a fixed and precise timing, with little flexibility? E.g. electronic dance music written on a sequencer with a fixed bpm per song would have simple and precise timing, whilst a recording of an orchestral piece performed by humans probably would not. Extracting beat timings will be a lot easier and simpler in the former case.  
  > **username_0**: @Neil Slater Ah, sorry about the confusion. No, no tempo rubato, no change in tempo, no pauses, no variation in speed and no variation in beat length. In this specific case, BPM is less about musical tempo and more of a technician's hack to slice time in regular intervals for the sake of data entry.  
  
  ---
  
  ## 0 answers
  
  