• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Convert to float and more
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Convert to float and more


  • Subject: Re: Convert to float and more
  • From: Jose Commins <email@hidden>
  • Date: Thu, 5 Jun 2003 22:05:14 +0100

If you don't like having your code waddle through the treacle that is known as C++ while converting int to float, here's some PowerPC code to perform int-to-float:

Input: r3 = int
Output fp1 = float

; Code
lfd fp4, itofloat(r7) ; Get the float -> float correcting constant.

xoris r8, r3, $8000
stw r8, -4(SP)
lis r8, 17200
stw r8, -8(SP)
lfd fp1, -8(SP)
fsub fp1,fp1,fp4
; Ta-da!


itofloat: dc.l $43300000, $80000000


Regards,
Jose.


On Wednesday, June 4, 2003, at 06:27 PM, Peter Mark wrote:

From: "Mark's Studio" <email@hidden>
Date: Wed Jun 4, 2003 9:46:54 AM Europe/London
To: email@hidden
Subject: Convert to float and more


Hi

I have a few questions.

Im working on a Cocoa sound editing app.

When i import a file i just copy the sound bytes into a NSData and keep
it in the original format.

All my drawing and DSP code use floats, so if the original sound format
is 16bit i do a lot of sample/32768.

I was thinking of converting the samples to float when importing the
file, but that will double the data size, so i still need to decide
what's best.

I tried to search the archives for the fastest way to convert from int
to float and back. but did not find much,
someone mentioned there might be a altivec snippet for converting?

I also looked at CASampleTools.cpp ( but to be honest i don't
understand C++).

When i play a file through the defaultAudioOutput, and the stream
format is not float, is there another conversion to float within
coreaudio?

I also want to import/export MP3 and other compressed formats what is
the best way to do that?


Thanks

Peter Mark

Mark's Recording Studio A/S
Lundeskovsvej 3 2900 Hellerup
Denmark
Tel: +45 35366078 Fax: +45 35366038
www.marks-studio.dk
email@hidden


--
The law of gravity says, "no fair jumping without coming down"
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Convert to float and more
      • From: Roy Lovejoy <email@hidden>
  • Prev by Date: Re: Convert to float and more
  • Next by Date: Re: Convert to float and more
  • Previous by thread: Re: Convert to float and more
  • Next by thread: Re: Convert to float and more
  • Index(es):
    • Date
    • Thread