how to record the voip call using sipsorcery sdk? - sip

I am using sample programs provided by sipsorcery:
https://github.com/sipsorcery/sipsorcery/tree/master/sipsorcery-softphonev2
What I want to record the call or record the part of one side spoken text, process it, then generate the answer test and speak it back.
What I need right now to process the spoken text. I wanted to record the parts of call and save them to a wav file and generate text from it. but it seems to me that I am doing wrong. I am not able to generate the correct wav file using the provided method of sipsorcery SDK.
I have tried to follow the example on this forum as well, but it didn't work
https://markheath.net/post/how-to-record-and-play-audio-at-same
I expect that this should work using a small temporary wave file at each time the user speaks a sentence and response back again playing back the processed response file.
Any guidance how can I achieve this sense of interception and processing of the call?
Thanks,
Vivek

This example should be pretty close to what you need. It plays the audio (only ulaw support) via the default speaker using NAudio. To record it should be a matter of switching from using NAudio playback to saving to a wav file.

Related

Try to nAudio read the wave file wile you record it

as I wrote in the title I need to read the wave file, from an external application, while it is recording it. I noticed that until I use StopRecording () and Dispose ()
the wave file remains locked and the external application tells me the file is locked for reading
Do you have any suggestions on how I can do it?
Thank you
Mimmo
I should read the file as if it were some kind of real time
That's really hard to do successfully. One trick I've used in the past is to create a large blank WAV file and have one process overwrite it in advance of the process that is reading.
But generally I'd recommend using something like a BufferedWaveProvider to supply audio for playback in a streaming scenario.

Download Result of Source Destination (Web Audio API)

I'm building a tool to edit audio with the Web Audio API.
Here is where I'm stuck:
...
source
.connect(gainNode)
.connect(analyser)
.connect(analyser2)
.connect(audioCtx.destination);
};
What I've written (which ends with the code above) successfully allows the user to upload a file, apply effects, and listen to it on play(). How would I then allow the user to click a button to export the results to a WAV file?
I've tried several methods online that have not worked for my use case.
Please let me know if more code is needed. Thank you for taking a look!
If you want a WAV file, I think you have to do that yourself. WAV files are quite simple. In this case, you'll need to add either a ScriptProcessorNode or AudioWorkletNode just before the destination to capture all the audio and convert it to a WAV file that can be downloaded.
If a compressed file is ok, you can look into MediaRecorder to save the data for you.
I ended up solving this by writing an entirely different script to download the file using OfflineAudioContext.
My original script plays the audio with effects, and the second script downloads it with the same effects. Now to figure out why there is latency on the effects while using OfflineAudioContext.

Record audio, add effects, then save result to a audio file

I am having trouble doing what the title said. My goal is to be able to add any desired effects to your recording, save the modified audio, then send that to a server.
I have searched the fourms and came across these threads:
viewtopic.php?f=7&t=13029&p=45362&hilit=saving#p45362
viewtopic.php?f=7&t=12660&p=44586&hilit=saving#p44586
viewtopic.php?f=7&t=13178&p=45746&hilit=saving#p45746
After reading those, I see it is possible to save the modified audio, but can it only be saved as a wav? Like I said after it is saved it will be sent to a server, so size is a big deal and wavs are relatively big compared to other formats. Ignoring that fact, I tried to implement FMOD_OUTPUTTYPE_WAVWRITER and I cannot get that to work; are there any good examples of using it? I looked though the examples in the library but I didn't see any..
But the basic structure of the app is to record, turn some switches off and on to see what filters you want, preview it, then press a button "Save" that will save it. What would this save function consist of?
Any help appreciated, thanks.
Using FMOD_OUTPUTTYPE_WAVWRITER is fairly straight forward, you set the type via System::setOutput, specify the output file via System::init extradriverdata. The extradriverdata should be an absolute path to a writable area of the device such as the documents directory. After you have finished playing, call System::release and the file will be complete.
The other option for recording wave data with effects is by creating a custom DSP and connecting it to the channel playing the recorded data. You will then get regular callbacks giving you float data that you must write out to disk yourself. You can find examples of DSPs and writing wav files in the dsp_custom and recordtodisk examples respectively.
Finally note that FMOD doesn't come with the facility to write compressed audio to disk, you will need another API to achieve this goal.
You can save as an AAC file via the ExtAudioFile API.

Streaming and playing an MP3 stream. .mp3 URL format

I used the sample code from http://cocoawithlove.com/2008/09/streaming-and-playing-live-mp3-stream.html. it runs OK with default URL. But when I replace with my URL "http://dl.mp3.kapsule.info/fsfsdfdsfdserwrwq3/fc90613208cc3f16ae6d6ba05d21880c/4b5244f0/b/7e/b7e80afa18d06fdd3dd9f9fa44b51fc0.mp3?filename=Every-Day-I-Love-You.mp3", this app shows an message as "Audio not Found". But when I put my URL on Address Bar of Web Browser, I can download this .mp3 file.
really, I can't understand why it is?
pleased tell me!
Thank you very much
My guess would be that the app is designed to play a MP3 encoded audio stream with no limit in length (which is different from your ordinary music file). To set this up, you need a streaming server on the client side.
I think you can find out for sure by trying with a different radio station that transmits in MP3. If that works, it's most likely that your app doesn't like your file.
You should, as Vivek recommends, also try using a simpler download URL for your file, in case the App gets confused by the URL's length and/or structure.
As mentioned, this is due to the URL of the file. The AudioStreamer code specifically checks for the extension of the file and tries to figure out the audio type based on that. If you change that logic to handle your custom URLs, it will start working
So to point you in the right direction: open AudioStreamer.m and look for the references of
hintForFileExtension:
This function returns the type of file based on the extension. If you know the file type won't change (always mp3), the quick and dirty solution is to always assign mp3 type without any logic... like this:
err = AudioFileStreamOpen(self, MyPropertyListenerProc, MyPacketsProc, kAudioFileMP3Type, &audioFileStream);
Note: I've put kAudioFileMP3Type constant instead of calculated value
PS yes, it does work with static mp3 files, even though it's designed for streams and hence misses some of the functionality one would expect from a player that plays a static file on the server (caching, prefetching, proper seeking)
Thats because the default url directly points to a file in the webserver, whereas the the url you've mentioned is a HTTP (POST/GET) operation, which the application may not be designed to handle.
I suspect that your URL is one-time-use. When I try to visit it, I see 408 - Request Timeout.
Many links on mass file sharing websites are like this. If you could download the file directly, you wouldn't sit through a page of ads and premium account offers.
Try again with a file on a normal website, like this one.

How to embed control change commands inside of a MIDI file

I am making a simple game in order to learn a new language. I am in the process of collecting some music for the game and would like to use the MIDI format so that I can control the flow of the track (i.e., I would like to have an introduction that only plays once and does not play again when the song loops.)
I am having a tough time finding information on how to modify existing MIDI files so that they may send a control change signal to the synthesizer. Has anyone had experience with this?
I think that I should have been more clear with my original question. I am using an existing game engine which takes care of playing the music. I am under the impression that this control change value must be embedded directly in the MIDI file itself as I have no control over the synthesizer. From the manual:
MIDI files are played via the
DirectMusic Synthesizer. If a BGM MIDI
file contains the control change value
111, that value is recognized as where
the song will start repeating after it
reaches the end.
I wish I could do it programmatically. I suppose what I am after here is some sort of editor which will allow me to modify the MIDI file that I already have.
Sounds like what you really want is a midi editor
try looking in the Midi 1.0 spec
Here's a table of the control change messages though it looks like you're looking for a way to do this in software. yes?
you could try just sending it as raw midi data (ie. the messages on that table)
looking over your question again... my answer is not that useful...
what I would do if I were you is separate the introduction into it's own file and then you have a file containing just what you want to loop.
you could also look at the spec for the Standard Midi File format (SMF)
DirectMusicProducer is probably your best free option if you are playing using DirectMusic. I don't believe the MIDI record feature will include control changes, but your engine may support playing segment files which are much more flexible.
The only MIDI sequencer I use cost around $300 (USD) about 10 years ago (and no longer appears to exist), but I am not aware of any good quality free MIDI file sequencers. (Note that "MIDI editor" is probably different to "MIDI file editor" or "MIDI sequencer")