I am using a sensor whose value am reading in matlab. Once the sensor value reaches a threshold, a sound note is to be heard. I have saved the sound as a .wav file which am reading at the beginning of the code. If threshold is reached, am using soundsc function to play the .wav file. This .wav file is just of duration 0.2 seconds. But when I run this code, I notice there is a time lag between the sensor reaching the threshold and the audio note being heard. The purpose of the sensor is to give real time auditory feedback, that's why it is important that there is no lag. Just for testing I used the beep function in matlab, this gives me real time sound when threshold is reached. Thus, there is no issue with the data acquisition process, the issue is with the soundsc function. Is there any solution to this? has anyone used matlab for real time audio feedback?