Search Results

Search found 1022 results on 41 pages for 'pseudo'.

Page 8/41 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Split UInt32 (audio frame) into two SInt16s (left and right)?

    - by morgancodes
    Total noob to anything lower-level than Java, diving into iPhone audio, and realing from all of the casting/pointers/raw memory access. I'm working with some example code wich reads a WAV file from disc and returns stereo samples as single UInt32 values. If I understand correctly, this is just a convenient way to return the 32 bits of memory required to create two 16 bit samples. Eventually this data gets written to a buffer, and an audio unit picks it up down the road. Even though the data is written in UInt32-sized chunks, it eventually is interpreted as pairs of 16-bit samples. What I need help with is splitting these UInt32 frames into left and right samples. I'm assuming I'll want to convert each UInt32 into an SInt16, since an audio sample is a signed value. It seems to me that for efficiency's sake, I ought to be able to simply point to the same blocks in memory, and avoid any copying. So, in pseudo-code, it would be something like this: UInt32 myStereoFrame = getFramefromFilePlayer; SInt16* leftChannel = getFirst16Bits(myStereoFrame); SInt16* rightChannel = getSecond16Bits(myStereoFrame); Can anyone help me turn my pseudo into real code?

    Read the article

  • NHibernate : Root collection with an root object

    - by Daniel
    Hi, I want to track a list of root objects which are not contained by any element. I want the following pseudo code to work: IList<FavoriteItem> list = session.Linq<FavoriteItem>().ToList(); list.Add(item1); list.Add(item2); list.Remove(item3); list.Remove(item4); var item5 = list.First(i => i.Name = "Foo"); item5.Name = "Bar"; session.Save(list); This should automatically insert item1 and item2, delete item3 and item3 and update item5 (i.e. I don't want to call sesssion.SaveOrUpdate() for all items separately. Is it possible to define a pseudo entity that is not associated with a table? For example I want to define the class Favorites and map 2 collection properties of it and than I want to write code like this: var favs = session.Linq<Favorites>(); favs.FavoriteColors.Add(new FavoriteColor(...)); favs.FavoriteMovies.Add(new FavoriteMovie(...)); session.SaveOrUpdate(favs); FavoriteColors and FavoriteMovies are the only properties of the Favorites class and are of type IList and IList. I do only want to persist the these two collection properties but not the Favorites class. Any help is much appreciated.

    Read the article

  • Alter a function as a parameter before evaluating it in R?

    - by Shane
    Is there any way, given a function passed as a parameter, to alter its input parameter string before evaluating it? Here's pseudo-code for what I'm hoping to achieve: test.func <- function(a, b) { # here I want to alter the b expression before evaluating it: b(..., val1=a) } Given the function call passed to b, I want to add in a as another parameter without needing to always specify ... in the b call. So the output from this test.func call should be: test.func(a="a", b=paste(1, 2)) "1" "2" "a" Edit: Another way I could see doing something like this would be if I could assign the additional parameter within the scope of the parent function (again, as pseudo-code); in this case a would be within the scope of t1 and hence t2, but not globally assigned: t2 <- function(...) { paste(a=a, ...) } t1 <- function(a, b) { local( { a <<- a; b } ) } t1(a="a", b=t2(1, 2)) This is somewhat akin to currying in that I'm nesting the parameter within the function itself. Edit 2: Just to add one more comment to this: I realize that one related approach could be to use "prototype-based programming" such that things would be inherited (which could be achieved with the proto package). But I was hoping for a easier way to simply alter the input parameters before evaluating in R.

    Read the article

  • question about partition

    - by davit-datuashvili
    i have question about hoare partition method here is code and also pseudo code please if something is wrong correct pseudo code HOARE-PARTITION ( A, p, r) 1 x ? A[ p] 2 i ? p-1 3 j ? r +1 4 while TRUE 5 do repeat j ? j - 1 6 until A[ j ] = x 7 do repeat i ? i + 1 8 until A[i] = x 9 if i < j 10 then exchange A[i] ? A[ j ] 11 else return j and my code public class Hoare { public static int partition(int a[],int p,int r) { int x=a[p]; int i=p-1; int j=r+1; while (true) { do { j=j-1; } while(a[j]>=x); do { i=i+1; } while(a[i]<=x); if (i<j) { int t=a[i]; a[i]=a[j]; a[j]=t; } else { return j; } } } public static void main(String[]args){ int a[]=new int[]{13,19,9,5,12,8,7,4,11,2,6,21}; partition(a,0,a.length-1); } } and mistake is this error: Class names, 'Hoare', are only accepted if annotation processing is explicitly requested 1 error any ideas

    Read the article

  • How to multi-thread this?

    - by WilliamKF
    I wish to have two threads. The first thread1 occasionally calls the following pseudo function: void waitForThread2() { if (thread2 is not idle) { return; } notifyThread2IamReady(); while (thread2IsExclusive) { } } The second thread2 is forever in the following pseudo loop: for (;;) { Notify thread1 I am idle. while (!thread1IsReady()) { } Notify thread1 I am exclusive. Do some work while thread1 is blocked. Notify thread1 I am busy. Do some work in parallel with thread1. } What is the best way to write this such that both thread1 and thread2 are kept as busy as possible on a machine with multiple cores. I would like to avoid long delays between notification in one thread and detection by the other. I tried using pthread condition variables but found the delay between thread2 doing 'notify thread1 I am busy' and the loop in waitForThread2() on thear2IsExclusive() can be up to almost one second delay. I then tried using a volatile sig_atomic_t shared variable to control the same, but something is going wrong, so I must not be doing it correctly.

    Read the article

  • Database PK-FK design for future-effective-date entries?

    - by Scott Balmos
    Ultimately I'm going to convert this into a Hibernate/JPA design. But I wanted to start out from purely a database perspective. We have various tables containing data that is future-effective-dated. Take an employee table with the following pseudo-definition: employee id INT AUTO_INCREMENT ... data fields ... effectiveFrom DATE effectiveTo DATE employee_reviews id INT AUTO_INCREMENT employee_id INT FK employee.id Very simplistic. But let's say Employee A has id = 1, effectiveFrom = 1/1/2011, effectiveTo = 1/1/2099. That employee is going to be changing jobs in the future, which would in theory create a new row, id = 2 with effectiveFrom = 7/1/2011, effectiveTo = 1/1/2099, and id = 1's effectiveTo updated to 6/30/2011. But now, my program would have to go through any table that has a FK relationship to employee every night, and update those FK to reference the newly-effective employee entry. I have seen various postings in both pure SQL and Hibernate forums that I should have a separate employee_versions table, which is where I would have all effective-dated data stored, resulting in the updated pseudo-definition below: employee id INT AUTO_INCREMENT employee_versions id INT AUTO_INCREMENT employee_id INT FK employee.id ... data fields ... effectiveFrom DATE effectiveTo DATE employee_reviews id INT AUTO_INCREMENT employee_id INT FK employee.id Then to get any actual data, one would have to actually select from employee_versions with the proper employee_id and date range. This feels rather unnatural to have this secondary "versions" table for each versioned entity. Anyone have any opinions, suggestions from your own prior work, etc? Like I said, I'm taking this purely from a general SQL design standpoint first before layering in Hibernate on top. Thanks!

    Read the article

  • Querying for a unique value based on the aggregate of another value while grouping on a third value

    - by Justin Swartsel
    So I know this problem isn't a new one, but I'm trying to wrap my head around it and understand the best way to deal with scenarios like this. Say I have a hypothetical table 'X' that looks like this: GroupID ID (identity) SomeDateTime -------------------------------------------- 1 1000 1/1/01 1 1001 2/2/02 1 1002 3/3/03 2 1003 4/4/04 2 1004 5/5/05 I want to query it so the result set looks like this: ---------------------------------------- 1 1002 3/3/03 2 1004 5/5/05 Basically what I want is the MAX SomeDateTime value grouped by my GroupID column. The kicker is that I DON'T want to group by the ID column, I just want to know the 'ID' that corresponds to the MAX SomeDateTime. I know one pseudo-solution would be: ;WITH X1 as ( SELECT MAX(SomeDateTime) as SomeDateTime, GroupID FROM X GROUP BY GroupID ) SELECT X1.SomeDateTime, X1.GroupID, X2.ID FROM X1 INNER JOIN X as X2 ON X.DateTime = X2.DateTime But this doesn't solve the fact that a DateTime might not be unique. And it seems sloppy to join on a DateTime like that. Another pseudo-solution could be: SELECT X.GroupID, MAX(X.ID) as ID, MAX(X.SomeDateTime) as SomeDateTime FROM X GROUP BY X.GroupID But there are no guarantees that ID will actually match the row that SomeDateTime comes from. A third less useful option might be: SELECT TOP 1 X.GroupID, X.ID, X.SomeDateTime FROM X WHERE X.GroupID = 1 ORDER BY X.SomeDateTime DESC But obviously that only works with a single, known, GroupID. I want to be able to join this result set on GroupID and/or ID. Does anyone know of any clever solutions? Any good uses of windowing functions? Thanks!

    Read the article

  • Should I use an interface or factory (and interface) for a cross-platform implementation?

    - by nbolton
    Example A: // pseudo code interface IFoo { void bar(); } class FooPlatformA : IFoo { void bar() { /* ... */ } } class FooPlatformB : IFoo { void bar() { /* ... */ } } class Foo : IFoo { IFoo m_foo; public Foo() { if (detectPlatformA()} { m_foo = new FooPlatformA(); } else { m_foo = new FooPlatformB(); } } // wrapper function - downside is we'd have to create one // of these for each function, which doesn't seem right. void bar() { m_foo.bar(); } } Main() { Foo foo = new Foo(); foo.bar(); } Example B: // pseudo code interface IFoo { void bar(); } class FooPlatformA : IFoo { void bar() { /* ... */ } } class FooPlatformB : IFoo { void bar() { /* ... */ } } class FooFactory { IFoo newFoo() { if (detectPlatformA()} { return new FooPlatformA(); } else { return new FooPlatformB(); } } } Main() { FooFactory factory = new FooFactory(); IFoo foo = factory.newFoo(); foo.bar(); } Which is the better option, example A, B, neither, or "it depends"?

    Read the article

  • Logging network activity of LAMP server using BASH

    - by Yarin
    I've got a Fedora LAMP server on Amazon EC2 functioning as a HTTP pseudo-proxy (Sorry, don't know the terminology- It's not a true proxy where requests are relayed through apache, rather client requests are being translated by a PHP script, which then sends a new request.) I'd like to be able to fully log the HTTP cycle CLIENT - PROXY PROXY - SERVICE SERVICE - PROXY PROXY - CLIENT I'm hoping to do this using BASH tools- thinking netcat? Looking for advice and examples. Thanks!

    Read the article

  • Virtual PC with Multi Monitors

    - by user41013
    Hi I have recently intalled Virtual PC and was wondering if it possible to make use of both of my monitors with it. I have managed to get a pseudo multi screen effect by connecting using Remote Desktop connection, but this isn't really what i wanted. Is this possible? Thanks

    Read the article

  • Virtual PC with Multi Monitors

    - by user34710
    Hi I have recently intalled Virtual PC and was wondering if it possible to make use of both of my monitors with it. I have managed to get a pseudo multi screen effect by connecting using Remote Desktop connection, but this isn't really what i wanted. Is this possible? Thanks

    Read the article

  • Put Conky behind the desktop icons

    - by Michal Gow
    Maybe I am trying do something impossible, but after hours of Googling I didn't get 100% answer yet. So - it is possible put Conky on Desktop backgroud (behind desktop icons)? The usual config: own_window yes own_window_type normal # (desktop, override) - I have the same result for all this attributes own_window_transparent yes own_window_hints undecorated,below,skip_taskbar,sticky,skip_pager Is giving me Conky with (pseudo)transparent background in front of icons (they are completely hidden behind it, even if in background of Conky is shown background image), while I am trying achieve opposite... My system: SuSE 11.4 KDE 4.4 (Release 3) x86_64

    Read the article

  • Konsole Read/Write Access to PTY Device

    - by Carmen
    When I run something like: $ konsole -e "sleep 30" I get this message Konsole is unable to open a PTY (pseudo teletype). It is likely that this is due to an incorrect configuration of the PTY devices. Konsole needs to have read/write access to the PTY devices. But if I try to run this: $ gnome-terminal -e "sleep 30" Then it is fine, and it does not throw any error. How can I change the read/write access of the Konsole to the PTY devices?

    Read the article

  • How to get the Vista taskbar to span multiple monitors?

    - by NoCarrier
    I can't for the life of me get the vista taskbar to span multiple monitors. I've searched and looked far and wide, and alas the only pseudo-solution i can find is Ultra-Mon, but a) it doesn't quite look the same and b) i don't want to have to pay for something that Windows really ought to be able to do out of the box. Does anyone have a solution for this? Will this get addressed in Windows 7?

    Read the article

  • what's the safest OS?

    - by Bob
    I have pretty important stuff on my PC (using Windows). All the programming files, passwords etc. And now I thought: Is that even safe to store all this information on a hard drive? What if some virus (or a pseudo-antivirus gets it) M.b. it is better to buy Mac for this purpose? I kinda don't like Linux, cause I hate making million small decisions manually (what drivers to install etc) Will like to hear some opinions.

    Read the article

  • understanding evaluation function

    - by mish
    I am developing a chess program. And have made use of an alpha beta algorithm and a static evaluation function. I have successfully implemented both but I want to improve the evaluation function by automatically tuning the weights assigned to its features. At this point am totally confused about the policy suitable for updating the weights of the function. One policy I have in mind is to check whether a move is good or bad before updating weights but I really know how to implement it. Thus I need ideas and pseudo code please.

    Read the article

  • HTG Explains: What “Everything Is a File” Means on Linux

    - by Chris Hoffman
    One of the defining features of Linux and other UNIX-like operating systems is that “everything is a file.” This is an oversimplification, but understanding what it means will help you understand how Linux works. Many things on Linux appear in your file system, but they aren’t actually files. They’re special files that represent hardware devices, system information, and other things — including a random number generator. These special files may be located in pseudo or virtual file systems such as /dev, which contains special files that represent devices, and /proc, which contains special files that represent system and process information. How to Banish Duplicate Photos with VisiPic How to Make Your Laptop Choose a Wired Connection Instead of Wireless HTG Explains: What Is Two-Factor Authentication and Should I Be Using It?

    Read the article

  • How do I make good guy attacks only hit bad guys and vice versa?

    - by tieTYT
    My game has many different type of good guys and many different type of bad guys. They will all be firing projectiles at each other but I don't want any accidental collateral damage to occur for either alignment. So bad guys should not be able to hit/damage other bad guys and good guys should not be able to hit/damage other good guys. The way I'm thinking of solving this is by making it so that the Unit instance (this is javascript, btw), has an alignment property that can be either good or bad. And I'll only let collision happen if the class Attack boolean didAttackCollideWithTarget(target) return attack.source.alignment != target.alignment and collisionDetected(attack.source, target) This is pseudo-code, of course. But I'm asking this question because I get the sense that there might be a much more elegant way to design this besides adding yet another property to my Unit class.

    Read the article

  • Difference Procedural Generation and Random Generation

    - by U-No-Poo
    Today, I got into an argument about the term "procedural generation". My point was that its different from "classic" random generation in the way that procedural is based on a more mathematical, fractal based, algorithm leading to a more "realistic" distribution and the usual randomness of most languages are based on a pseudo-random-number generator, leading to an "unrealistic", in a way, ugly, distribution. This discussion was made with a heightmap in mind. The discussion left me somehow unconvinced about my own arguments though, so, is there more to it? Or am I the one who is, in fact, simply wrong?

    Read the article

  • design pattern advice: graph -> computation

    - by csetzkorn
    I have a domain model, persisted in a database, which represents a graph. A graph consists of nodes (e.g. NodeTypeA, NodeTypeB) which are connected via branches. The two generic elements (nodes and branches will have properties). A graph will be sent to a computation engine. To perform computations the engine has to be initialised like so (simplified pseudo code): Engine Engine = new Engine() ; Object ID1 = Engine.AddNodeTypeA(TypeA.Property1, TypeA.Property2, …, TypeA.Propertyn); Object ID2 = Engine.AddNodeTypeB(TypeB.Property1, TypeB.Property2, …, TypeB.Propertyn); Engine.AddBranch(ID1,ID2); Finally the computation is performed like this: Engine.DoSomeComputation(); I am just wondering, if there are any relevant design patterns out there, which help to achieve the above using good design principles. I hope this makes sense. Any feedback would be very much appreciated.

    Read the article

  • Alpha blend 3D png texture in XNA

    - by ProgrammerAtWork
    I'm trying to draw a partly transparent texture a plane, but the problem is that it's incorrectly displaying what is behind that texture. Pseudo code: vertices1 basiceffect1 // The vertices of vertices1 are located BEHIND vertices2 vertices2 basiceffect2 // The vertices of vertices2 are located IN FRONT vertices1 GraphicsDevice.Clear(Blue); PrimitiveBatch.Begin(); //if I draw like this: PrimitiveBatch.Draw(vertices1, trianglestrip, basiceffect1) PrimitiveBatch.Draw(vertices2, trianglestrip, basiceffect2) //Everything gets draw correctly, I can see the texture of vertices2 trough //the transparent parts of vertices1 //but if I draw like this: PrimitiveBatch.Draw(vertices2, trianglestrip, basiceffect2) PrimitiveBatch.Draw(vertices1, trianglestrip, basiceffect1) //I cannot see the texture of vertices1 in behind the texture of vertices2 //Instead, the texture vertices2 gets drawn, and the transparent parts are blue //The clear color PrimitiveBatch.Draw(vertice PrimitiveBatch.End(); My question is, Why does the order in which I call draw matter?

    Read the article

  • Why is it impossible to produce truly random numbers?

    - by Vinoth Kumar
    I was trying to solve a hobby problem that required generating a million random numbers. But I quickly realized, it is becoming difficult to make them unique. I picked up Algorithm Design Manual to read about random number generation. It has the following paragraph that I am fully not able to understand. Unfortunately, generating random numbers looks a lot easier than it really is. Indeed, it is fundamentally impossible to produce truly random numbers on any deterministic device. Von Neumann [Neu63] said it best: “Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin.” The best we can hope for are pseudo-random numbers, a stream of numbers that appear as if they were generated randomly. Why is it impossible to produce truly random numbers in any deterministic device? What does this sentence mean?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >