Wikipedia:Reference desk/Archives/Computing/2015 June 12

Computing desk
< June 11 << May | June | Jul >> June 13 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


June 12 edit

iTunes and external disc edit

My Mac's main HD is crowded; music takes up a third of it. I copied the music to a mostly unused external disc. In iTunes preferences, I changed "iTunes Media folder location" to the external, but this has had no apparent effect; it's still playing from my home directory. What can I do? —Tamfang (talk) 08:19, 12 June 2015 (UTC)[reply]

How do you know that you are still playing from your home directory? —SGA314 (talk) 15:28, 12 June 2015 (UTC)[reply]
  • I open a track's info box and look for "File location". —Tamfang (talk) 01:27, 13 June 2015 (UTC)[reply]
If the files are on the external drive, and space is limited on your internal, why keep the files on the internal drive? Dismas|(talk) 17:48, 12 June 2015 (UTC)[reply]
that was one of my thoughts to. —SGA314 (talk) 17:52, 12 June 2015 (UTC)[reply]
delete all music you dont use — Preceding unsigned comment added by A8v (talkcontribs) 21:10, 12 June 2015 (UTC)[reply]
  • I'll delete the files from the internal drive after confirming they'll play from the external. —Tamfang (talk) 01:27, 13 June 2015 (UTC)[reply]
Just a few thoughts on that...
A) When moving them to the external, the files themselves shouldn't have changed, so I don't see what danger there is in deleting the internal drive files.
B) I can confirm that they'll play from an external drive since this is the way that my music and movies are set up. A Mac Mini with an external drive for just the iTunes library. Barring something unique about your system, I don't know why it wouldn't work.
C) You could do a test on a small number of files (or even just one). Delete the internal drive copy, try to play the external. If it works, that would suggest that the external files are playable. Dismas|(talk) 04:51, 13 June 2015 (UTC)[reply]
  • A) Call me a cockeyed pessimist.
  • B) Did you always have it on external? If not, how did you transition?
  • C) And how do I "try to play the external"?
  • I suppose I could delete the internal files and then, whenever iTunes complains "I can't find that file," point it to the external. I'd only have to do that 15641 times. —Tamfang (talk) 09:12, 13 June 2015 (UTC)[reply]
My library has been moved from computer to computer a couple times. As for the Mini that it is currently hooked up to, it's always been on the external drive with that specific computer. As far as playing a file from the external drive: In the Finder, navigate to the file you want to play, double click it. Your default music player (iTunes, presumably) should open and play the file. Dismas|(talk) 23:56, 13 June 2015 (UTC)[reply]

Addenda: I prefer not to risk losing the "last played" or "play count" or "date added" metadata. — This may be the first time in ten years that The Missing Manual is no help at all, by the way. — One possibility is to trick the filesystem into treating the external directory as a subdirectory of $HOME. How hard/dangerous is that? Does it need to be a whole volume? —Tamfang (talk) 09:12, 13 June 2015 (UTC)[reply]

Have you tried going to iTunes Preferences then Advanced, then press the change location iTunes media location. Dja1979 (talk) 23:03, 13 June 2015 (UTC)[reply]
  • Yes, as I said in the first place. —Tamfang (talk) 08:38, 14 June 2015 (UTC)[reply]
Have you read this thread? Dismas|(talk) 09:00, 14 June 2015 (UTC)[reply]
  • Now I have. It points to [1] . . . . and it's now copying the files. I'll report when it finishes. —Tamfang (talk) 19:27, 14 June 2015 (UTC)[reply]
  • It seems to have worked. Hurrah!
      Resolved
    Tamfang (talk) 20:51, 14 June 2015 (UTC)[reply]

Algorithm to write proper sine and square waves using python's wave module? edit

Hello everyone. Here is a tricky question(at least for me). Does anyone know the proper algorithms to write sine and square waves to a .wav file (not both in the same file though)? I am using python's wave module to do this. I found an article that describes Linear pulse code modulation and how it works. It even gives a chart that depicts the values of a sine wave. However, I have found nothing that is really beneficial to me. My current method doesn't produce sine or square waves, but I can produce great white noise though(Hint: It uses random numbers). Here is some properly written samples of a 440 Hz square wave:

Frame 0 = '\x00\xcd\xcc\x0c'
Frame 1 = '\x00\xcc\xcc\x0c'
Frame 2 = '\x00\xce\xcc\x0c'
Frame 3 = '\x00\xcc\xcc\x0c'
Frame 4 = '\x00\xcd\xcc\x0c'
Frame 5 = '\x00\xce\xcc\x0c'
Frame 6 = '\x00\xcb\xcc\x0c'
Frame 7 = '\x00\xce\xcc\x0c'
Frame 8 = '\x00\xcc\xcc\x0c'
Frame 9 = '\x00\xcd\xcc\x0c'

I got this by using the wave module in python 2.7.6. The file was generated with Audacity. I used an audio track with a type of 32-bit float and a sample rate of 44100 Hz. I exported with an uncompressed codec and I used a header of type Microsoft WAV and an encoding type of Signed 16 bit PCM Signed 32 bit PCM. Thanks for your help in advance. —SGA314 I am not available on weekends (talk) 19:56, 12 June 2015 (UTC)[reply]

Your sample will have to come out of a sine function. Say you have samplerate (44100), frequency (440). Get values from math.sin(2*pi*frequency*samplenumber/samplerate), varying sample number from 1,2,3,.... And yes there looks to be a math.cos() function in Python as well. THe sin and cos use input in radians, so that is why the 2π is there. (disclaimer I have never programmed Python). Convert these values, that vary from -1.0 to 1.0 to your PCM range, is that -32768 to 32767 by multiplying by 32767 and converting to integer; math.floor may do this. Graeme Bartlett (talk) 22:11, 13 June 2015 (UTC)[reply]
@Graeme Bartlett: Sorry it took me so long to reply. What would my PCM range be? And what is the variable "samplenumber?" Oh and should I convert the integer to hexdecimal? —SGA314 I am not available on weekends (talk) 15:24, 15 June 2015 (UTC)[reply]
As it turns out, I am actually using a encoding type of Signed 32 bit PCM. Not Signed 16 bit PCM. —SGA314 I am not available on weekends (talk) 19:11, 15 June 2015 (UTC)[reply]
Edit: Updated the audio data for the square wave with the Signed 32 bit PCM audio data instead of the Signed 16 bit PCM audio data. —SGA314 I am not available on weekends (talk) 21:13, 15 June 2015 (UTC)[reply]
Wave files have a particular format, and from what I remember they are either 8 bit or 16 bit signed integers, they can be mono or stereo. When you write to the wave file it will have to be in binary form, including use of x00 characters. I have some code I wrote about 20 years ago in a C-- which is 386 assembler and c — it probably won't help you. The PCM range is the smallest value to the biggest value, I gave the numbers for a 16 bit coding, for 8 bit it might be -127 to +127, But I think it may be coded differently say 0 to 255. the samplenumber is just a counter that counts how many samples you have made. So after 1 second you will be up to number 44100 and after 2 seconds it will have counted up to 88200. You will just have to count up to duration*samplerate. I did not explain square waves, but they will be positive for a number of samples and then negative for the same number of samples. Graeme Bartlett (talk) 13:30, 16 June 2015 (UTC)[reply]
Ok I now understand what you meant by the samplecounter. But what are x00 characters? and I tried to write to the file in binary form but it still was not a 440 Hz sine wave. I think my problem is that I'm not using the proper PCM range. I think I'm exporting in a Signed 32 bit PCM format. That would mean my PCM range would be -2147483648 to 2147483647, or 0 to 4,294,967,294. Right? I guess worst case scenario, I am not exporting in a Signed 32 bit PCM format, so I would have to try PCM ranges from 8 bit to 32 bit. —SGA314 I am not available on weekends (talk) 15:42, 16 June 2015 (UTC)[reply]

10 lines code/day? edit

The Mythical Man-Month claims that the average output for a software engineer is 10 lines of code/day. Was it the case back then when the book was published? Is it true nowadays? --Scicurious (talk) 17:41, 12 June 2015 (UTC)[reply]

Well, from my POV, I can write in excess of 1,000 lines of code a day(given me enough time in a day that is). And I would think that more expirenced programmers could do even more than that. I guess that back then, code was very hard to write and thus took longer to write, because they were probably using either straight binary or assembly. That only applies though if your talking about that days before the first version of C, which I assume you are. —SGA314 (talk) 17:51, 12 June 2015 (UTC)[reply]
I don't know, but I encourage you to read Source_lines_of_code#Disadvantages before you put much stock in that number. Some days I can write hundreds of lines of simple code, some days I spend all day optimizing just a few lines. None of that matters as much as what the code does, and how well it does it. SemanticMantis (talk) 17:54, 12 June 2015 (UTC)[reply]
True to that. I didn't really think about the complexity of the code being written. Good point. —SGA314 (talk) 18:10, 12 June 2015 (UTC)[reply]
I can't find a statement that programmers produce 10 lines of code per day in Brooks. But Chapter 8, "Calling the Shot", is based on a number of studies of actual programming projects. So I would say that Brooks' results are base on actual experience, not some off-the-cuff guess. On page 88 Brooks explains that the productivity figures for large projects includes "planning, documentation, testing, system integration, and training times". He mentions a few small projects with much higher productivities. Jc3s5h (talk) 18:15, 12 June 2015 (UTC)[reply]
Corbató's Data, p. 93:
"MIT's Project MAC reports, however, a mean productivity of 1200 lines of debugged PL/I statements per man-year on the MUL TICS system (between 1 and 2 million words)." If there are 240 work days in a year, and half the staff are developers, that turns into 10 lines of code per person working in the project. --Scicurious (talk) 18:42, 12 June 2015 (UTC)[reply]
Of note, the final count excludes code written and discarded. For example, management asks for some new cool feature. It is implemented, tested, and shown to management. They then say that they don't like it, so it is removed. All of those lines of code fail to make the final count of lines of code. So, I have a gut feeling that some people may be in this conversation thinking that lines of code means "how many lines of code does a programmer write" while others are quoting sources that use lines of code to mean "how many lines of code make it to the final product." 209.149.113.240 (talk) 19:24, 12 June 2015 (UTC)[reply]
  • The Mythical Man-Month is a great book, but I wonder how many people realize that all of its main conclusions are wrong. Things that Brooks claimed are impossible are nowadays routinely done in open source projects by unorganized groups of volunteers. The basic problem is that Brooks did not grasp the value of modularity: he assumed that a project would work best if every developer was familiar with every aspect of the project. The result was that his developers were overwhelmed by complexity. Nowadays any large project is routinely divided into modules connected by rigorously structured interfaces. A developer who knows the specifications for a module can work on it without knowing anything about the other modules: thus even newcomers can be productive if they are assigned to relatively simple modules. Generally speaking, the larger a project, the greater the proportion of effort that goes into laying out the modules and defining their interactions. This sort of organizational code is much easier to write than the "deep" code that programmers in Brooks's day spent most of their time on -- much of it is boilerplate -- so the average number of lines of code written in a day has gone way up. Looie496 (talk) 15:25, 13 June 2015 (UTC)[reply]
I seriously doubt that. Someone needs to modularise the design and create the interfaces. And developers who don't understand the overall design at least on a general level will misunderstand the specifications and produce useless code. Specifying a module to the level that it "just needs coding" is a management fiction - it's about as hard as coding it, but the tool support is a lot worse. Increases in productivity that we do have come from better languages and libraries, and better tools (both software and hardware). --Stephan Schulz (talk) 15:38, 13 June 2015 (UTC)[reply]
Brooks' most important conclusion, for which the book is named, is still very true, and that is that adding people to a project when it is behind schedule is not helpful because the people have to come up to speed, and then spends time on the part of the senior people to bring them up to speed. Robert McClenon (talk) 16:01, 13 June 2015 (UTC)[reply]
The lines of code count should not be lines of code per coder, but debugged lines of code per person, where the people include the managers, requirements engineers, testers, and other people. Also, counting lines of code isn't as easy as you might think, when there are tools that generate code behind the scenes, for instance. Robert McClenon (talk) 16:06, 13 June 2015 (UTC)[reply]
Of significance here is that it's not "10 lines of typing" - it's "10 lines of fully debugged, fully documented code that's made it through quality assurance, has a build environment, an installer, an uninstaller, an editing history, and assorted support files and configuration systems". Certainly there have been days when I've written one or two thousand lines of code and it "just worked" and resulted in an application so simple that a 5 line "README" was all of the documentation it needed. But then there have been entire weeks where I've been tracking down a single incorrect line of code that caused everything to fail - and I contributed -1 lines of code over 10 days.
The "gut feel" for most programmers that this is a crazily low number - but when you calculate an average over a large project from start to completion, the 10 lines per day metric is surprisingly close to reality. Another point to note is that programming is not like most other occupations where any two workers will produce broadly similar quantities of output. It's not at all unusual to find that the best programmers be several hundred times more productive than the worst programmers - even on a single project - and a bad programmer can actually produce negative output by inserting bugs that take other people on the team a long time to find.
The big problem here is that managers who believe in the 10 lines per day metric have no way to know in advance how many lines need to be written in order to complete the project - and programmers can more accurately estimate how long it will take to complete the project than they can estimate the number of lines of code that result. Personally, I don't give a damn how many lines of code are written per day - I care how much of the final project gets done each day - and the two concepts cannot possibly be related by any kind of simple metric. SteveBaker (talk) 02:21, 14 June 2015 (UTC)[reply]
Indeed. When I was in industry, one of the developers I trained in programming became so good that in most projects where he increased functionality by 20%, he reduced overall code size by 30%, just by refactoring and cleaning up the mess that had grown over the years. And my second-to-last job was mostly to act as a buffer between developers and management, to cushion the cultural differences. I gave a copy of The Mythical Man Month to our COO, but I doubt that he read it... --Stephan Schulz (talk) 08:32, 14 June 2015 (UTC)[reply]

online game not working edit

http://www.myabandonware.com/game/balance-of-power-the-1990-edition-li/play i have updated flash and java and i run windows 8.1 and i use a gaming PC that can run battlefeild at max graphics — Preceding unsigned comment added by A8v (talkcontribs) 21:09, 12 June 2015 (UTC)[reply]

What browser do you use? If it's Chrome, are you aware of this? Rojomoke (talk) 04:40, 13 June 2015 (UTC)[reply]
It does not work in Mozilla Firefox or Google Chrome but works in Internet Explorer. — Preceding unsigned comment added by A8v (talkcontribs) 14:47, 13 June 2015 (UTC)[reply]

How to unlock a used Sprint phone edit

My friend without internet access has asked me to ask at the refdesk 'how to unlock an iphone that has already finished its contract with Sprint network, so it can be used in another company'. This will save paying a hacker two month's wages if it can be done by following a set of instructions. I suppose a link to a page that has text instructions would be ideal, and again this is a 4s. Thanks for any help. μηδείς (talk) 21:52, 12 June 2015 (UTC)[reply]

The first thing to try is simply to contact Sprint; see http://www.sprint.com/legal/unlocking_policy.html. They say they will unlock a device no problem if the contract period is over and the account is in good standing. —Noiratsi (talk) 06:55, 13 June 2015 (UTC)[reply]
Thanks, I have passed this on, and I don't know the account details. I am also unsure that their 800 number will work where the user is calling from. μηδείς (talk) 23:36, 13 June 2015 (UTC)[reply]
  • The user has an iphone 4 with iOS 7.1.2. Not residing in the US calling the 800 number will not work, and attempting a chat with customer service would be almost impossible, and prohibitively expensive. There are two options open, $25 hack (a month's wages) that will allow in country calls and a $70 hack which would allow texts and emails out of country. Given the latter is almost 3 month's wages, some better option is what's desired--unfortunately I have no knowledge of how to effect any of this. Is jailbreaking possible without first unlocking the phone? (Even for that I understand one needs to download the app first, a catch 22. Thanks. μηδείς (talk) 01:33, 14 June 2015 (UTC)[reply]
It turns out the phone is only CDMA network compatible, which is not able to be used in the destination country. But as relatives are coming to the US I have advised them to make all the arrangements here first, rather than trying to call internationally uncallable numbers and access unaccessible websites. Thanks.
  Resolved