Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About valla2

  • Rank
  1. valla2

    Mp3 duration

    I think it's too much work for what i want to get. And it will be slow as i will do this operation to every mp3 file i find on the disk. I am actually writing a program that finds mp3 duplicates on the disk. Two mp3 files are duplicates when they are the same. So to check if 2 files are the same, i check the title of the song and the artist. But because many times an mp3 files doesn't have a title or an artist, or instead of that you can find a web address, i also check the duration of the file. So if 2 mp3 files have different duration, they are not the same, even if they have the same title or artist. Do you think this is how i should be doing it?
  2. valla2

    Mp3 duration

    Come on guys, nobody know how to do it? I don't ask for code, i just want to know the method. THanks :(
  3. valla2

    Mp3 duration

    Sorry but i really can't get it. I don't know how to read through the bitstream, and count the number of frames. In the binary representation of the file, what do i actually read? Can you post some pseudocode? I am sure it will make things clearer. Thanks. //edit: it isn't clear in the article of wikipedia
  4. Hi. I am making a program, and i need to get from an mp3 file the duration of the song. I can extract from the file the song title, the artist etc, but i don't know how to calculate the duration. I have searched google and i found this formula: duration = total-number-of-frames * samples-per-frame / sample-frequency samples-per-frame has a value of 1152 (for MPEG-1 Layer III) or 576 (for MPEG-2 Layer III). but i don't know how to use it ( i don't know how to get the number of frames, or the bitrate), nor what it means. I have no idea how to code something like that. Can anybody help me? I am using .Net by the way. Thanks.
  5. valla2

    Problem with SetTranform

    It's over my head right now :( Perhaps i should forget it and come back later. Thanks for your help though. Much appreciated.
  6. valla2

    Problem with SetTranform

    Not a single reply? :.(
  7. Hello. I have a question regarding the SetTranfrom method in the IDirect3DDevice9 class. What we have here is the texture of the background that gets rendered 2 times larger and tiled 10 times in both directions. The code for that is basically this: D3DXMATRIX texScaling; D3DXMatrixScaling(&texScaling, 10.0f, 10.0f, 0.0f); //this line says that the background will be tiled 10 times gd3dDevice->SetTransform(D3DTS_TEXTURE0, &texScaling); .. D3DXMATRIX S; D3DXMatrixScaling(&S, 20.0f, 20.0f, 0.0f); // this says that the background will be displaid 20 times larger mSprite->SetTransform(&S); mSprite->Daw(....); And here's the problem. gd3dDevice->SetTransform doesn't just tile the texture 10 times. If that's just what it does, then the texture should be diplayed 20 times larger, as the code for tranfrorming it uses the scaling matrix "D3DXMatrixScaling(&S, 20.0f, 20.0f, 0.0f);". What i want to say is that for the effect we want to achieve, shouldn't we rewrite that line like this D3DXMatrixScaling(&S, 2.0f, 2.0f, 0.0f); ? But If we make it like this then what we get is the texture much smaller and tiled together ( 10 times? you can't really tell ) and with a general size only 2 times bigger that the size of the original texture. The documentation for gd3dDevice->SetTransform doesn't explain it at all ( it says that it just "Sets a single device transformation-related state" ) -- I also have another question.Since we shouldn't use DirectInput8, what should we use? It was really good because we didn't have to place our code for the input in the main window procedure. Right?
  8. Hello people. I would like to start game programming in DirectX, and i intend to buy this book: Introduction to 3D Game Programming with Direct X 9.0c: A Shader Approach link: I am wondering if it is up-to-date and if it uses the latest version of DirectX. I mean, if i upgrade to Windows Vista, is DirectX 9.0c still going to work, or will there be a newer edition? Also, it seems that the book section of gamedev doesn't include it, so i would like to hear your opinion about this book, if you have read it. Thanks p.s: if you didn't find this book good it would be great if you could suggest a better one.
  9. Hm... that's bad.. I am using the Win32 API. Suppose i want to place a button in my main window. Are you saying that the only way to know in advance the x and y coordinates of the place i'll put it, is by placing a button ( dragin and dropin it ) in a Dialog Window in a resource editor ( ResEd works for me ) and then viewing the resource script generated and getting it's x,y position and height and width ( And then passing these values to CreateWindow )?
  10. Hi In MSVC++ 6.0, you can easily design a dialog window by draging and dropping components, using the built-in resource editor. What i want to do is do the same thing with my main window ( my form ). It seems to me that i can drag and drop only when designing a dialog window, and the resource script is generated automaticcally. How can i design my main window using a resource editor? My second problem is that i haven't yet figured out how to see the content of a recource script ( *.rc ) in VC++. I can only see the form or, say the icon of my resource, but not the resource code. How can i view it in MSVC++? thanks in advance
  11. I think that this problem is not NP-Complete (the Chinese postman problem is not ). >If you want a fast solution you can look up some genetic algoritms (like SA - simulated Annealing) that deal with approximate solutions of the TS problem and refine the base function to fit your problem. Approximate algorithms? But i want to be sure that my solution is 100% correct..
  12. Hi there. I 've got a problem with my graph. I want to visit all the edges of my graph, covering the shortest distance. It doesn't matter if i visit an edge or a vertex more than one time, as long as the total distance you cover is the shortest one. I start from a vetrex and i finish in another one. I'have searched in the net and i found out that it is quite similar to the Chinese postman problem ( ) but all the solutions i found for the problem just test if there is A path that traverses all the edges of a graph; they don't find the shortest route. Could anyone help me out? Any ideas?
  13. valla2

    Implementing Priority Queue in C++

    >Ah, Dijkstra's algorithm for the APSP or Kruskal for the LCST? Dijkstra's algorithm and Prim's algorithm... >Both of those algorithms rely on the graph being static. If the graph changes at all (like, a vertex has moved), you have to start all over again. Yeah, my graph is static.. >A set may be your best bet. Remember, though, that you can't modify an element in-place. You need to remove it from the set, modify it, and insert it anew. The only problem will be that i'll need O(n) time to find the place of the vertex i want to change in the set but it will surely be more straight forwoard than the same this using a queue. >Which will be expensive to keep consistent with the queue's structure. O(n) every time you modify the queue. Not a good proposition. Yes, except if i implement my own INSERT() function and make it in O(1) time. It's just one instruction. (something like "vertex.positionInQueue = indexOfThePosisionInTheHeap" ) But i think i found the optimal solution. I won't use any data structure for my purpose ( unlike Introduction to Algorithms ) Here's my code for Dijkstra's algo: #include <iostream> #include <list> #include <iterator> using namespace std; struct Vertex { list<int> adjList; list<int> adjWeight; int dist; int parent; } Graph[100]; void InitializeGraph( int source ) { for ( int i = 0; i < 100; ++i ) { Graph.dist = INT_MAX; Graph.parent = -1; } Graph[sourc].dist = 0; } int main() { int minDistance, prevMinDist, minVertex, source, u; cin >> source; cin >> the whole graph; InitializeGraph( source ); minVertex = source; minDistance = 0; prevMinDist = INT_MAX; for ( int i = 0; i < 100; ++i ) { u = minVertex; //Instead of a Priority Queue minDistance = prevMinDist; list<int>::iterator v = Graph.adjList.begin(), w = Graph.adjWeight.begin(); for ( ; v != Graph.adjList.end(); ++v, ++w ) { if ( Graph[*v].dist > Graph.dist + *w ) { Graph[*v].dist = Graph.dist + *w; Graph[*v].parent = u; if ( Graph[*v].dist < minDistance ) { minVertex = *v; // next in Priority prevMinDist = minDistance; minDistance = Graph[*v].dist; } } } } PrintShortestPath ( source, anywhere ); } How do you find it?
  14. valla2

    Implementing Priority Queue in C++

    for some reason i always get logged off If i implement the [] operator, every time i change the value of an element i'll have to call make_heap. In Dinkumware ( it says "The function evaluates the ordering predicate X < Y at most 3 * (last - first) times". That's O(n), but it can be done in O(lg n) if the elements only get decreased. It seems that the STL isn't the way to go in my case :(. I think i should make a new field in "Vertex" indicating the position in the queue, so that i can do: Q[u.AdjacencyList.PositionInQueue].distance = NewDistance; update the Q .. ( make_heap? it won't update the PositionInQueue field ) thanks... PS:All i want to do is use a priority queue for my minimum spanning tree or single-source shortest path algorithms implementation
  15. valla2

    Implementing Priority Queue in C++

    Thanks for the replies guys :) For some reason the code tags didn't work in the previous posts... I get your point, but i am still unsure about how i am going to implement this: Basiccally i want to transform the pseudocode in my book for finding shortest paths into C++ code: The code i want to transform is this: Q is a priority queue that keeps the vertices of a graph, and it is keyed on the distance of them from a source vertex. while Q is not empty u <- ExtractMin( Q ) .. for each i = 1 to u.AdjacencyListSize do u.AdjacencyList.distance = NewDistance; // if the NewDistance is the smallest of all the distances, // then the AdjacencyList vertex will be the top in the queue My problem is that i can't access directly the AdjacencyList vertex in my queue. I'll have to search for it in the queue yelding an O(n) operation which is too slow for such a trivial task :(. Imagine that each vertex is defined as follows: struct Vertex { list<int> AdjacencyList; // the vertices that directly communicate with this vertex (ie. to form edjes ) int distance; // distance from the source; //int identifier; // i don't want to place this field :( } Graph[ 100 ]; // a graph of 100 vertices; i 'll have to store in "Vertex" another field that will be the identifier of the vertex ( a number from 1 ... 100 ) and every time i want to change the distance of the i-th vertex i 'll have to search in the queue untill i find a vertex with "v.identifier == i", and then change it's "v.distance" to the new distance ( this must be done in O( lg n ) time ). (-i will only decrease the distances).
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!