Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 764509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:44:19+00:00 2026-05-14T16:44:19+00:00

I am streaming wav data from a flash application. If I get the data

  • 0

I am streaming wav data from a flash application. If I get the data and do the following:

f = File.open('c:/test.wav', 'wb')
f << wav_data.pack('c'*wav_data.length)
f.close

The wav file works perfectly. If I do this:

f = Tempfile.new('test.wav')
f << wav_data.pack('c'*wav_data.length)
f.close
FileUtils.mv(f.path, 'c:/')

The file is there, but sounds all garbled. Checking in a hex editor shows that everywhere the working file had an 0A (or \n), the garbled version had 0D0A (or \r\n)

I am using this in conjuction with rails+paperclip, and am going to be using a combination of Heroku and S3 for the live app, so I am hoping this problem will solve itself, but I’d like to get this working on my local machine for the time being.

Does anybody know of any reason FileUtils.mv would be doing this, and if there is a way to change its behaviour?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T16:44:20+00:00Added an answer on May 14, 2026 at 4:44 pm

    It looks like a binary file vs text file problem. You should set your file to binary with File#binmode as in:

    f = Tempfile.new('test.wav')
    f.binmode
    f << data
    

    You must have had a second argument to open in your first example, no? Something like “w+b”, probably… The “b” stands for binary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm streaming data from a CSV file and trying to import it to SQL
Problem: I'm streaming my video from a php file with stream_get_contents(); using Flowplayer as
Where to get streaming (live) video and audio from camera example for Nokia (5800
I am streaming out data (sometimes png, sometimes json, sometimes xml) and I get
I have an application streaming video from the device to a remote computer. When
Hey all, I'm writing an application which records microphone input to a WAV file.
Can anyone suggest any open source linux program for converting .wav files to flash
I am trying to play video from streaming url. the code is as following
Live streaming video in html 5 - what is required from server to stream
I have a streaming input which has repeated values. I can use any data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.