NAudio: is it possible to record in MP3 or AAC without using the filesystem? - naudio

I'm using NAudio for a project that needs to record voice using the microphone. The NAudio project has a very nice demo that shows how to record a wav file, but since I need to transfer the voice-data to a server using webservices, a wav file is often too large.
Therefore I was wondering if it possible to do the same in MP3 or AAC directly. In this article I read that it is not possible to encode to any other format using (memory) streams and that file paths are required. I cannot assume that my client application has access to the file system.
Is there any way to create or encode an MP3 file directly without using the filesystem?
Thank you in advance!

I'm afraid NAudio doesn't currently support doing that, but one technique that you could try is to use Lame.exe and pipe PCM into stdin and read the MP3 converted output from stdout.

Related

How to upload and download media files using GUNDB?

I'm trying to use GUN to create a File sharing platform. I read the tutorial and API but I couldn't find a general way to upload/download a file.
I hear that there is a limitation of 5Mb of localStorage in GUN, if I want to upload a large file, I have to slice it then storage it into GUN. But right now I can't find a way to storage file into GUN.
I read the question from Retric and I know how to store the image into GUN, but can I store the other type of Files such as .zip or .doc File? Is there a general API for file storage?
I wrote a quick little app in 35 lines of HTML to demonstrates file sharing for images, videos, sound, etc.
https://github.com/amark/gun/blob/master/examples/basic/upload.html
I've sent 20MB files thru it, tho yeah, I'm sure there is a better way of splitting it up into 2MB chunks - that is currently not automatic, you'd have to code it.
We'll have a feature in the future that will automatically split up video files. Do you want to help with this?
I think on the download side, all you have to do is make sure you have the whole file (stitch it back together if you do write a splitter upper), and add it to some <a href=" target. Actually, I'm not sure exactly how, but I know browsers support download file attributes for a few years now, where you can create a download link even of a in-memory file... but you'll have to search online for how. Then please write a tutorial and share it with the community!!
I would recommend using IPFS for file storage and GUN to store the links to those files. GUN isn't meant for file storage I believe, primarily user/graph data. Thus the 5 MB limitation.

Inserting wav file within a wav file using naudio

I have a recorder application(CSHARP) where i use NAudio to record/playback audio. Our need is to Insert and overwrite audio in an existing wav file.
Currently, for inserting audio, i use the current position of the wav file and do a split. Merge the new wav file to original one and merge with the rest of the file.
When overwrite, i take the current position of the original audio and merge the new audio from that position.
This process seem to work ok but for some reason i think reading the file and writing a file takes a big toll. When we do a fast recording,stop recording, rewinding, recording, stop recording and so on.. the request to file gets clogged up and at some point i get File IO exception error saying "The file is in use by another process.."
(Note: We use a footpedal equipment with 3 keys assigned for recording, play and rewind. The issue we have is when we bang on the pedals faster.)
i am really stuck at this point as i am unable to resolve this issue. I will need some expert help.
Is there a way to insert audio from a specific position in a file without doing Split and Merge? PLSSSSSSSSS Help!!
Overwriting audio in a WAV file is not too difficult, and when I need to do this, I use a customised version of WaveFileWriter that can open an existing WAV file, and lets you reposition within the data chunk.
Inserting on the other hand is always going to be problematic, since you need to shift all the audio after the insert point forwards. I'd be tempted to create a separate "insert" wav file, and then after your whole recording session is finished, stitch the parts together into a final WAV file.

Objective-C/Cocoa Chunked File Upload

I'm relatively new to Objective-C/Cocoa development. I'm currently working on a Mac application where i need to upload a file to a web server using HTTP PUT requests. I'd like to break up the file to several chunks and stream it to the server rather than reading the whole file into the memory and uploading it in one go.
I have come across several third party libraries (ie: ASIHTTPRequest, AFNetworking) which can support this functionality out of the box. However, i'd like to go ahead without using third parties for the time being due to several constraints of the project.
Any assistance in this regard is greatly appreciated. Thanks in advance :)
If you are just uploading a file, without a Multipart MIME wrapper, then I believe you can setup an input stream directly from NSMutableURLRequest. Getting an NSInputStream for a file on-disk is easy, using +[NSInputStream inputStreamWithFileAtPath:]. I've not done this exactly myself, but I think it will work.
If you do end up needing to do a Multipart MIME wrapper, then I'd recommend using a library. It is a total pain to get right, and has some quirks to deal with depending on what OS version you are running on.

Generate A Large File Inside s3 with .NET

I would to generate a big file (several TB) with special format using my C# logic and persist it to S3. What is the best way to do this. I can launch a node in EC2 and then write the big file into EBS and then upload the file from the EBS into S3 using the S3 .net Clinent library.
Can I stream the file content as I am generating in my code and directly stream it to S3 until the generation is done specially for such large file and out of memory issues. I can see this code help with stream but it sounds like the stream should have already filled up with. I obviously can not put such a mount of data to memory and also do not want to save it as a file to the disk first.
PutObjectRequest request = new PutObjectRequest();
request.WithBucketName(BUCKET_NAME);
request.WithKey(S3_KEY);
request.WithInputStream(ms);
s3Client.PutObject(request);
What is my best bet to generate this big file ans stream it to S3 as I am generating it?
You certainly could upload any file up to 5 TB that's the limit. I recommend using the streaming and multipart put operations. Uploading a file 1TB could easily fail in the process and you'd have to do it all over, break it up into parts when you're storing it. Also you should be aware that if you need to modify the file you would need to download the file, modify the file and re-upload. If you plan on modifying the file at all i recommend trying to split it up into smaller files.
http://docs.amazonwebservices.com/AmazonS3/latest/dev/UploadingObjects.html

DotNetZip - create zip from accessed file

it is possible to use DotNetZip to create a zip from an accessed file (eg log file from another application) ?
so create a zip when the log file gets written through the other application
Hmm, well, yes, if you are willing to write some code.
One way to do it is to compress the file AFTER it has been written and closed.
You would need to have an app that runs with a filesystem watcher, and when it sees the log file being closed, it compresses that log file into a zip.
If you mean to imply, a distinct app that writes to a file and it automagically writes into a zip file, no I don't know of a simple way to do that. There is one possibility: if the 3rd party app accepts a System.IO.Stream in which to write the log entries. In that case, you can do that with DotNetZip. You can get a writeable stream from DotNetZip, into which the app writes content. It is compressed as it is written, and when the writing is complete, DotNetZip closes the zipfile. To use this, check the ZipFile.AddEntry() method that accepts a WriteDelegate. It's in the documentation.