Computer Science Questions 2
September 14th, 2008 | Published in C, Computer Science, Digital Signal Processing, Operating Systems, Programming, Speech Technologies | 3 Comments
Again, I'll be answering some questions I've received in my inbox, just like in the previous post of this series.
- I want to know how to declare a const variable in one file and access it from other files? (C++) by Ricardo Orozco (Venezuela).
It's a fairly basic question, and reveals that you have to study more C++. What you want is to define a
constvariable at global scope. Unlike non-constvariables (which areexternby default),constvariables are local to the file in which they are defined. Therefore, you cannot access them from other files unless you specify that the variable isextern.For instance, if you specify
externwhen defining the variablebufferSizein file1.ccextern const int bufferSize = 512;you can access
bufferSizefrom any other file, say, file2.ccextern const int bufferSize; // we are using bufferSize from file1.cc - I'm just starting to study speech synthesis, and I'm faced with the calculus of resonances in an uniform acoustic tube. The glottal end is closed, but the mouth is open. Could you expand on this? by Bakuman.
This is the configuration you are studying:

The acoustic tube is uniform, and its length is L. The glottis, located at x=-L, is closed (infinite impedance) and the mouth, located at x=0, is open (impedance zero). Now, pressure variation p(x) along this uniform acoustic tube is expressed as:
where f represents frequency in Hz, and c is the speed of sound:
at 37° C.
According to the boundary conditions (the impedances at both ends), the solution is:
where
is the peak in sound pressure. On the other hand, we have a relation between pressure and volume velocity
is a constant representing the tube's area. Now, volume velocity can be expressed as
where
equals the average atmospheric density (
at 37°C).
As U(−L) = 0, resonances Fn of the acoustic tube are
where n=1, 2, 3... And that's it. We can see that the area function does not affect the location of resonances. Finally, remember that, in average, the male oral tract has a length of 16.9 cm, and the female tract has an average length of 14.1 cm.
- What's an stub? by Dani Hoffmann (Colombia).
It really, really depends on the context. Your question is too ambiguous. A Stub may even be a relative of the Danish poet Ambrosius Stub. After all, code is poetry.
In computing, I know of 4 contexts where the word stub has a well-established meaning:
- Web Sites: A stub is a web page in progress, i.e., a page which provides minimal information and is intended for later development. For instance, a Wikipedia stub is a short article in need of expansion.
- Coding: During development, we sometimes use a "skeleton" function (or procedure, or method) to simulate some intended (but not yet implemented) functionality. For instance, the function may stand in for a complex algorithm to be developed later, or simulate a procedure running on a remote host. Such placeholder function is called a stub function. Stub functions come in handy for quick prototyping and testing.
- Distributed Systems: In distributed systems, a service interface defines the services available to programs. These services are distributed among several networked machines. In distributed systems, a program in machine A may request a service by calling a procedure. However, the procedure may be offered by a remote host, say, machine B. Remote Procedure Calls (RPC) are a paradigm of distributed systems aimed at abstracting the communication between hosts in a network. The goal of RPCs is to hide the details of the remote call. The remote call should look like a local one, i.e., the program in machine A would invoke the procedure in machine B as it would invoke a procedure locally. Under the hood, though, it's obvious that we have to transmit information from the client (caller) to the server (callee), and in the other direction. Now, how to hide the fact that we are calling a procedure located in other machine? This is the basic idea of RPCs:
- In the address space of the client, we represent the server procedure by means of a local procedure called client stub. Likewise, the server is also linked to a server stub, which will receive the message from the client stub.
- When machine A requests a service which is provided by machine B, a call is made to the client stub (which has the same name as the procedure in B). As the client stub lies in the same address space of the caller, the invocation is handled locally, and the program sees this invocation as a local one. However, the client stub marshalls the received parameters and sends them, throught the network, to the server stub. In turn, the server stub unmarshalls the parameters and perform the call to the real procedure in the server. When the server procedure finishes, results or exception data travels back, from server to client. By the way, marshalling is the process of taking a collection of data items (such as the procedure name and its arguments) and grouping them according to some predefined representation, suitable for transmission over the network. The server should know and conform to this representation in order to unmarshall the received data and recover the transmitted information.
Albeit conceptually simple, there are some interesting (nasty) problems for implementing RPCs, such as passing pointer arguments (remember that client and server have different address spaces).
- Computer Networking: A stub network is a network or part of network with only one communication path to external networks (non-local hosts). For instance, if we connect to our Internet Service Provider using only one router, our local network is a stub network with respect to our provider.
There is other related context for stubs: in electronics, we identify Stub sections, which are mostly used for impedance matching in transmission lines. But I'm not too familiar with this "stub" meaning.
As always, it was a pleasure to answer your questions. Thank you very much.

September 15th, 2008at 10:36 pm(#)
why “const variables” rather than “constants” ?? “const x” means that x is a constant… “const variable” doesn’t make sense!
September 19th, 2008at 3:53 am(#)
A stub is always a placeholder, a skeleton, something that acts on behalf of other thing.
August 23rd, 2009at 1:08 pm(#)
zinahahuwi…
Vtunnel Com School …