mardi 27 janvier 2015

Generating tremolo sine wave

I'm trying to create a tremolo by oscillating between two 430Hz and 450Hz, storing the 16-bit sample in the list wav. However, the audible frequency seems to increase range of oscillation across the entire clip. Does anyone know why?



# wavtools.py

defaults = {
'nchannels': 1,
'sampwidth': 2,
'framerate': 44100,
'comptype' : 'NONE',
'compname' : None,
}

def sinegen(f, a):
"""
generator for a sin wav
f: the frequency of the sin wave
a: the amplitude of the sin wave
"""
(i, n) = (0, defaults['framerate'] / f)
while True:
yield a * math.sin(2 * math.pi * i / n)
i += 1



# tremolo.py

maxamp = 2**15 - 1
foscillator = wavtools.sinegen(1, 10)
nframes = 6 * wavtools.defaults['framerate']

wav = []
for t in range(nframes):
f = (440 + next(foscillator)) / wavtools.defaults['framerate']
w = 2 * math.pi * f
x = w * t
y = maxamp * math.sin(x)
wav.append(y)

HTML Audio Element with a fixed source URL where the audio file is recreated on the Apache server after each access by the client

The goal is to detect each time a HTML / Javascript client loads a specific audio file from an Apache Web Server and then replace the file that was just loaded by the client with a new one for the next time the user requests an audio file (reading pages in a story) (e.g. a new file with the same URL as the previous one). Multiple users will be accessing the system and each will get a unique series of audio files created for them based upon their user preferences and the content that they are accessing / studying.


My two questions are:




  1. How can I get Apache to detect when a specific audio file is accessed by a client and then kick off an action within either an application running on the web server (Java) or on the O/S?




  2. What would the best way to name / store the continually recreated audio files such that the files created for each user are kept separate? (I'm considering using the username (which is unique) or using a UUID for the file name...)




C# language processing libraries

I am looking to create a program that reads in audio, and will highlight on-screen whichever word the audio is currently playing, and then move on to the next word at the appropriate time (think karaoke...the word is highlighted until the next word is spoken). What would be the best C# library for this type of audio/language processing?


I have the following code that should mute audio when window is focused, but I must have done something wrong since it doesn't mute at all;


script



$(function() {
$(window).focus(function() {
console.log('Focus');
/*getElementById('notificationsound').muted = true;*/
$("#notificationsound").prop('muted', true); //mute

});

$(window).blur(function() {
console.log('Blur');
});
});


html



<audio id="notificationsound" src="sound/notify.mp3" preload="auto"></audio>


The goal is for the notification sound to be played only when the page is not viewed / out of focus (I'm using this "script structure" since it's likely I'll add more to the different states later on).


I know I'm missing something very basic since I'm a beginner, and since it logs focus/blur in the console correctly. Also – I know this most likely is a very similar question to others asked here before, but I could only find rather aged answers (which my code is based upon) so if this is not the "modern" or best practice anymore I'd love examples of alternate methods.


Examples are very much appreciated in case of major change is needed or suggested.


Pausing sounds with SoundCloud API

I'm fairly new to JS and I'm having trouble getting audio that is currently playing to pause or stop using the SoundCloud JavaScript SDK. I'm using a MEAN stack.


In the 'ready' function I initialize the SC player:



SC.initialize({
client_id: "my_client_ID",
redirect_uri: "http://ift.tt/1v0LYB0",
});

...

$('#trackList table tbody').on('click', 'td a.linkplaytrack', playTrack);
$('#trackList table tbody').on('click', 'td a.linkpausetrack', pauseTrack);


The playTrack function works fine and audio starts playing:



function playTrack(event){
event.preventDefault();

SC.stream("/tracks/293", function(sound){
sound.play();
});
};


But for some reason the pauseTrack function doesn't work:



function pauseTrack(event){
event.preventDefault();

SC.stream("/tracks/293", function(sound){
sound.pause();
});
};


Any help, insights or suggestions would be appreciated!


Use a bluetooth headset as a extended microphone for a camcorder using android phone

I'm trying to film a video with a camcorder. However, the camcorder isn't support bluetooth microphone. Fortunately, I think I found a way to do it, but I can not find good app to do it. My plan is, use phone as a bluetooth receiver, and connect the audio port of the phone to the camcorder via cable. I need: an app that make the bluetooth headset as a default microphone of the system. an app that make the sound from the bluetooth mic able to flow to the audio port.


I know about an app called "megaphone" in Apple store that makes sound from the phone's mic flows through to the phone's audio port. But I can not use the bluetooth headset for it.


Any suggestion please?


USB Sound assertion in AppleUSBAudioDevice with return 0xE000404F at line 3834

My MacBook Pro is running 10.10.1. My company is building a USB audio device. When I plug that device into a USB port on my Mac, I see this message appear in the console log:


1/27/15 3:58:59.000 PM kernel[0]: USB Sound assertion in AppleUSBAudioDevice with return 0xE000404F at line 3834


Can someone please explain what this assertion means?


The device is a microphone, and it appears to be functioning properly.


Thanks.


-Matt