I'm currently working on a project that has been relatively easy, up until now. The underlying project is to transmit data/messages over lasers using audio transformation.
In a nutshell the process is currently like this

The user enters a message
Message is turned into binary
For each 1 and 0 in the binary message, it plays a corresponding tone to signal which is which, in my case 250hz for a 1 and 450 hz for a 0.
The outgoing tone is sent over a stereo cable to an audio transformer rigged to a laser
A solar panel acts as a microphone and records the incoming "sound" as a file
It them plays the file back and reads off the tones and tries to match each 250 and 450 hz to a 1 or 0 (which is where my issue lies).

Up until the actual processing of the sound is fine, my current issue is the following. 
I play the tones each for x time, on the receiving end it is recorded for y time, y time is cut sampled many times and then analyzed sample by sample which then logs each frequency. This is inefficient and inaccurate. I have had many issues regardless of the time I play the tones for it often hears a tone twice or doesn't hear it at all, which completely throws off whole messages.
I have tried to match the rate at which it samples with the time each tone plays, but unless aligned accordingly it does not work. I've only had a few successful tests for messages like 'test' and 'hi'. I have already looked into bpsk and fsk, but I feel as if I'm already doing something like it but that I have a bad receiving end to decipher it all.
This is all written in Python and I'd be very grateful for any tips, suggestions, or possible implementations that you can provide. Also for tone emission I'm using pyaudiere and for recording I'm using pyaudio.
Thanks!
-Steve
I would tackle the receiving end using two FIR filters, one for each frequency that you are trying to detect. The coefficients of the filters are just a copy of the signal you are looking for (i.e. 250Hz in one case and 450Hz in the other). You would have to look at the output of your solar panel to decide whether that is a square wave, sine wave, or something in between. The length of the filter corresponds to the duration of the tone (i.e. 'x' in your question). The samples are fed into both filters in parallel.
The output of each filter needs to be rectified (i.e. take the absolute value) and smoothed. The smoothing can be done using a simple moving average over a period of about half x (you can experiment to find the best value). Then if you compare the smoothed values (i.e. is a>b, or b>a) you should get a stream of 0's and 1's.
Things to be aware of: This assumes the channel behaves the same for both frequencies (i.e. you get similar snr and attenuation). You might need to tweak your frequencies a bit because 450Hz is quite close to 500Hz which is a harmonic of 250Hz.
Python Audio Transfer Through Lasers