text: Hop_Size meaning in aubio
  I'm trying to use the aubio() library for pitch detection. I'm trying to use the API for C and one of the parameters of the
  new_aubio_pitch function is
  hop_size. What does
  hop_size mean and how do you choose one?
  1 answer
  - answered 2018-07-11 09:35 fdcpp
  Hop Size should refer to the number of samples in between successive frames. For signal analysis, Hop Size should be less than the frame size, so that frames overlap.
  In this diagram the Hop Size would be 'Q' and 'K' is the frame size for a signal 's(n)'
  If your follow up question is 'why would you do that?', then there is a good answer to be found at this topic here:
  See also questions close to this topic
  - How to check scanf input that is not identifiable by %
  I have the following line of code that reads in input from a text file:
  a = scanf("(%d)%[^(](%d)(%d)", a1, arr, b1, c1);
  A normal line of input from this file would be: (4)1234(1)(1234)
  Is there a way with
  scanf()to identify a specific input item that does not match the template format that is sent, aside from checking the
  %d? (missing a parenthesis in beginning, etc.) Ex.
  4)1234(5)(1234)
  Based on my research, it seems like this may be difficult to do with
  scanf(), maybe even impossible since
  scanf()returns
  4(for this case), but I would like to see if there is a workaround that can be performed.
  - Write a program to check if the given string is balanced or not (Balancing Parenthesis)
  Write a program to check if the given string is balanced or not (Balancing Parenthesis) If string is balanced print YES else print NO
  Mandatory
  Create Stack Using stack mystack;
  Use push and pop operations Use mystack.pop for popping an element from the stack , & mystack.push to push an element to the stack;
  Use mystack.pop to pop an element and mystack.push to push an element to the stack.
  Input: }][}}(}][))]
  Output:NO
  I am getting error in this.
  My code:
  #include<bits/stdc++.h> #include<string.h> using namespace std; bool areParanthesisBalanced(string expr) { stack<char>mystack; char x; for (int i=0; i<expr.length(); i++) { if(expr[i]=='('||expr[i]=='['||expr[i]=='{') { mystack.push(expr[i]); continue; } if (mystack.empty()) return false; switch (expr[i]) { case ')': x = mystack.top(); mystack.pop(); if(x=='{' || x=='[') return false; break; case '}': x = mystack.top(); mystack.pop(); if (x=='(' || x=='[') return false; break; case ']': x = mystack.top(); mystack.pop(); if (x =='(' || x == '{') return false; break; } } return (mystack.empty()); } int main() {char expr; getline(cin,expr); if (areParanthesisBalanced(expr)) cout<<"YES"; else cout<<"NO"; return 0; }
  ERROR:
  no matching function for call to ‘getline(std::istream&, char&)’ getline(cin, expr);
  - C Hash Table with String Keys. Strings are equal to -14336?
  I'm trying to implement a hash table with keys of strings. I don't care about the values, so they are ints of 1. I need the speed of a hash look-up so no binary searches in arrays. My key strings are not being stored correctly, they print as expected when they are inserted, but when I display the hash table's contents, the keys are all -14336
  Please help
  #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdbool.h> #define SIZE 103141 * 2 #define MAXCHAR 1000 struct DataItem { int data; char* key; }; struct DataItem* hashArray[SIZE]; unsigned long hashCode(char *key) { unsigned long hash = 5381; int c; while (c = *key++){ hash = ((hash <<5)+ hash)+c; } return hash % SIZE; } struct DataItem *search(char *key) { unsigned long hashIndex = hashCode(key); //move in array until an empty while(hashArray[hashIndex] != NULL) { if(hashArray[hashIndex]->key == key){ return hashArray[hashIndex]; } //go to next cell ++hashIndex; //wrap around the table hashIndex %= SIZE; } return NULL; } void insert(char* key,int data) { struct DataItem *item = (struct DataItem*) malloc(sizeof(struct DataItem)); item->data = data; item->key = key; unsigned long hashIndex = hashCode(key); //move in array until an empty or deleted cell while(hashArray[hashIndex] != NULL && hashArray[hashIndex]->key != NULL) { //go to next cell ++hashIndex; //wrap around the table hashIndex %= SIZE; } // this statement below prints the keys correctly printf("%d %s %d\n",hashIndex,item->key,item->data); hashArray[hashIndex] = item; } void display() { int i = 0; for(i = 0; i<SIZE; i++) { if(hashArray[i] != NULL) // here the keys are printed as -14336 printf(" (%d,%d)\n",hashArray[i]->key,hashArray[i]->data); else printf(" .. \n"); } } int main() { struct DataItem* item; char *probefile = "cychp_pruned_r2_0.1.ids.txt"; FILE *probef; char str[MAXCHAR]; char *p; char *probe_name; probef = fopen(probefile,"r"); while (fgets(str, MAXCHAR, probef) != NULL){ p = strtok(str,"\n"); insert(p,1); } display(); // this exists in the file char *probe = "S-4TNIU"; // if I insert it here, it works //insert(probe,1); // not found item = search(probe); if(item != NULL) { printf("Element found:%s %d\n", probe,item->data); } else { printf("Element not found [%s]\n",probe); } }
  - Using a different url for a JavaScript audio visualizer
  I’m wondering, is there a way to make it so that i can use a cross origin url for the audio source instead of a raw one i have on github? Take a look at my code and see if there is anyway way i can do that. So basically i asking, how can i use a link like or. In Addition to that, does anyone know if i can make a line that follows the spot I’m at?
  // AUDIO CONTEXT window.AudioContext = (window.AudioContext || window.webkitAudioContext || window.mozAudioContext || window.oAudioContext || window.msAudioContext); if (!AudioContext) alert('This site cannot be run in your Browser. Try a recent Chrome or Firefox. '); var audioContext = new AudioContext(); var currentBuffer = null; // CANVAS var canvasWidth = window.innerWidth, canvasHeight = 120 ; var newCanvas = createCanvas (canvasWidth, canvasHeight); var context = null; window.onload = appendCanvas; function appendCanvas() { document.body.appendChild(newCanvas); context = newCanvas.getContext('2d'); } // MUSIC LOADER + DECODE function loadMusic(url) { var req = new XMLHttpRequest(); req.open( "GET", url, true ); req.responseType = "arraybuffer"; req.onreadystatechange = function (e) { if (req.readyState == 4) { if(req.status == 200) audioContext.decodeAudioData(req.response, function(buffer) { currentBuffer = buffer; displayBuffer(buffer); }, onDecodeError); else alert('error during the load.Wrong url or cross origin issue'); } } ; req.send(); } function onDecodeError() { alert('error while decoding your file.'); } // MUSIC DISPLAY function displayBuffer(buff /* is an AudioBuffer */) { var drawLines = 500; var leftChannel = buff.getChannelData(0); // Float32Array describing left channel var lineOpacity = canvasWidth / leftChannel.length ; context.save(); context.fillStyle = '#080808' ; context.fillRect(0,0,canvasWidth,canvasHeight ); context.strokeStyle = '#46a0ba'; context.globalCompositeOperation = 'lighter'; context.translate(0,canvasHeight / 2); //context.globalAlpha = 0.6 ; // lineOpacity ; context.lineWidth=1; var totallength = leftChannel.length; var eachBlock = Math.floor(totallength / drawLines); var lineGap = (canvasWidth/drawLines); context.beginPath(); for(var i=0;i<=drawLines;i++){ var audioBuffKey = Math.floor(eachBlock * i); var x = i*lineGap; var y = leftChannel[audioBuffKey] * canvasHeight / 2; context.moveTo( x, y ); context.lineTo( x, (y*-1) ); } context.stroke(); context.restore(); } function createCanvas ( w, h ) { var newCanvas = document.createElement('canvas'); newCanvas.width = w; newCanvas.height = h; return newCanvas; }; loadMusic('');
  EDIT 1 So i understand that i should have the files in github, but I’m just wondering if i could just use a different source for
  loadMusic('');i want to use a link like. Or something like that.
  - Outputting many .wavs from an S4 object made from a large (350 mb) .wav cut into 5 second segments
  Using the R code found here:
  Split an audio file into pieces of an arbitrary size
  I was looking to slice my audio into 5 second seconds, and then export them all as .wavs. After using the code above I was able to get an S4 object with 2564 elements which are waves with 6 slots each.
  I want to be able to save each of these as a .wav, but am a bit lost. Here is my code so far.
  # Calling the packages library(seewave) library(audio) library(tuneR) # Load audio wave into object Rec12234 <- readWave("012234.wav") # Make sure the file loaded correctly - should show sample rate, etc. head(Rec12234) #Set frequency freq <- 16000 # Set the length totlen <- length(Rec12234) #Set the duration totsec <- totlen/freq # How long each sample is (in seconds) seglen <- 5 #Defining the break points breaks <- unique(c(seq(0, totsec, seglen), totsec)) index <- 1:(length(breaks)-1) #Splitting the file items <- lapply(index, function(i) Rec12234[(breaks[i]*freq):(breaks[i+1]*freq)])
  I am very new to coding and R, so I do apologize if the answer is pretty easy!
  Thanks for the help!
  - Mix_SetPanning isn't being called properly in Mix_ChannelFinished callback function
  I'm using SDL_Mixer for my current project, and I'm trying to sync up sounds via the Mix_ChannelFinished function. It seems to let me be able to call Mix_PlayChannel, but it doesn't let me call Mix_SetPanning in the function. This results in the queued audio being much louder. Me calling it outside the function does help, but there is a noticeable gap of loudness at the beginning of the queued audio.
  Here's the function I call when a sound is finished:
  void playQueueSound(int channel) { printf("\n playing %d", channels[channel].soundIndex); if (channels[channel].soundIndex > (-1)) { //printf("\n playing %d", channels[channel].soundIndex); AudioSource::getSource(channels[channel].objId)->removeSound(channel); channels[channel].soundIndex = (-1); if (channels[channel].queueIndex > (-1)) { if (Mix_PlayChannel(channel, soundEffects[channels[channel].queueIndex].chunk, channels[channel].queueLoopMode)<0) { printf("\n cant play %s", Mix_GetError()); } setObjPanning(AudioSource::getSource(channels[channel].objId), channel); channels[channel].soundIndex = channels[channel].queueIndex; } else { channels[channel].objId = -1; } channels[channel].queueIndex = -1; channels[channel].queueLoopMode = 0; } }
  - Building aubio library on Windows outputs .lib files instead of .so and .a files
  I built the aubio library using the
  scripts/build_androidscript, and it resulted in
  aubio.liband
  aubio-5.dllfiles, but when I did this on linux, it resulted in
  libaubio.soand
  libaubio.afiles. This makes sense to me since the
  .soand
  .afiles are linked, which isn't supported on Windows, and from what I've read you can't even load .so files on Windows. How do I import these files into an Android NDK project? No matter what I do, it looks for
  .sofiles, and not
  .lib.
  Thanks!
  - Aubio - Building for Android on Windows
  I tried building the aubio library on Linux, and I managed to do it successfully, the only problem is that I need to transfer the entire thing to Windows. But it seems that the library files are symlinked, and Windows doesn't support them. So I had to build on Windows, and I got the following error. The build process looks like it completed just like on Linux, judging by the messages, but the last message was an error instead of success.
  Error:
  -error LNK2019: unresolved external symbol htons referenced in function aubio_sink_wavwrite_do D:\WinDir\Documents\aubio\build\src\aubio-5.dll : fatal error LNK1120: 1 unresolved externals * Node D:\WinDir\Documents\aubio\build\src\aubio.lib is created more than once (full message on 'waf -v -v'). The task generators are: 1. 'aubio' in D:\WinDir\Documents\aubio\src 2. 'aubio' in D:\WinDir\Documents\aubio\src If you think that this is an error, set no_errcheck_out on the task instance Waf: Leaving directory `D:\WinDir\Documents\aubio\build' Build failed -> task in 'aubio' failed with exit status 1120: {task 65659056: cshlib cvec.c.1.o,fmat.c.1.o,fvec.c.1.o,audio_unit.c.1.o,ioutils.c.1.o,sink.c.1.o,sink_apple_audio.c.1.o,sink_sndfile.c.1.o,sink_wavwrite.c.1.o,source.c.1.o,source_apple_audio.c.1.o,source_avcodec.c.1.o,source_sndfile.c.1.o,source_wavread.c.1.o,utils_apple_audio.c.1.o,lvec.c.1.o,mathutils.c.1.o,notes.c.1.o,onset.c.1.o,peakpicker.c.1.o,pitch.c.1.o,pitchfcomb.c.1.o,pitchmcomb.c.1.o,pitchschmitt.c.1.o,pitchspecacf.c.1.o,pitchyin.c.1.o,pitchyinfast.c.1.o,pitchyinfft.c.1.o
  I'm using r17 of Android NDK on Windows 10, and I'm trying to build for Android 21 for ARM. Doesn't matter anyway, since changing any of these variables doesn't solve the error.
  Even better would be if someone actually had a guide on how to build this on Windows.
  Thanks for your help!